Skip to main content

Questions tagged [alias]

An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

To create an alias for grep and to include directories

Frequently I'm using grep to search for some text in a bunch of folders, e.g. grep --include='*.csv' -nRHI --color=always 'pattern' Folder1 Folder2 I'd like to create an alias something like alias ...
athos's user avatar
  • 125
0 votes
1 answer
40 views

zsh, .bash_profile, and aliases

I have a script downloaded from the Internet, the beginning of which looks like this: echo "alias myip='curl -s https://api.ipify.org/'" >> ~/.bash_profile echo "alias myiplookup='...
jsx97's user avatar
  • 843
0 votes
0 answers
25 views

Command invoked from one path, "which" says it should be invoked from elsewhere [duplicate]

I've built an executable which, for the sake of this question, is named foo. There is already a version of it at /usr/bin/foo, and I install a different version as /usr/local/bin/foo. My path has /usr/...
einpoklum's user avatar
  • 10.1k
0 votes
0 answers
21 views

Understanding syntax of output from alias [duplicate]

I don't understand how to read the string and the escaping of the following output from listing aliases > alias foo="echo 'hello'" > alias ... alias foo='echo '\''hello'\''' ... It ...
hl5619's user avatar
  • 1
0 votes
2 answers
71 views

Bash - get file count

I have the following alias defined in my .bashrc alias lsfc='ls -l "$@" | tee /dev/tty | grep -v / | echo "File count: `wc -l`"' which is intended to give me the number of ...
David Shaw's user avatar
2 votes
2 answers
81 views

Can you fix this error while creating alias for encryption and decryption by GPG in z-shell?

I wanted to make a .zshrc alias with the help of these previous aliases present to make an alias to convert a compressed gpg to its original uncompressed folder or file... However, I am facing this ...
DarKnightz's user avatar
-1 votes
1 answer
147 views

Override tr in ~/.bashrc

I'm trying to create a function to translate words via a custom script: function mean() { ~/scripts/translate.sh $1 } I would prefer the function to be named tr, as it is much shorter and faster ...
algonell's user avatar
3 votes
1 answer
190 views

How to overload / customize bash (or any other shell) commands handler?

When in bash some non existing command is run, corresponding error message appears: $ non-existent-command non-existent-command: command not found Is it possible to customize this behavior? I would ...
Anton Samokat's user avatar
0 votes
1 answer
62 views

Get a list of all user's commands from a non-interactive shell

I am writing a script that would automatically suggest some new aliases/functions to be added to a user's shell config. Before doing that, however, I would like to make sure the aliases being ...
zoickx's user avatar
  • 51
0 votes
1 answer
66 views

zsh alias does not complete fully if not sourced once a day

vi ~/.zsh alias k='kubectl' complete -o default -F __start_kubectl k alias kga='k get all,ingress' If I do not source .zsh every day it does not take into account the ingress part of the kga alias. ...
dfs's user avatar
  • 1
0 votes
2 answers
125 views

How to write an alias or bash script that renames a single file using the same syntax as the `ren` command of Windows?

I am a long-term a Windows user, so I find the syntax of the ren command both simple and convenient: ren C:\pathTo\myFile\oldFileName.txt newFileName.txt [Update 24 July 2024] To be clear about my ...
ps.pf's user avatar
  • 3
4 votes
1 answer
1k views

Are there alternatives to alias I'm not aware of?

Today I started to notice weird behavior running a local command for a binary installed through Go. It seems the command is aliased, but consulting alias, it isn't. The command buf somehow executes cp!...
Tim's user avatar
  • 1,074
3 votes
2 answers
333 views

how to alias the `history` function in fish shell

I'm trying to set the fish history pager to be bat -l fish for syntax highlighting. (i.e. set the PAGER environment variable bat -l fish just for the history command). I tried: # 1: alias history &...
matan h's user avatar
  • 149
0 votes
3 answers
79 views

How to escape both single quotes and exclamation marks in bash

I have a long command and I just want to use alias to shorten it. But the command contains single quotes and exclamation marks. The origin command is ldapsearch -x -H ... -w 'abc!123'. I tried alias ...
Donghua Liu's user avatar
2 votes
0 answers
46 views

Can't unalias then redefine as a function in the same conditional [duplicate]

Here is a simplified implementation of an issue in my bash/zsh aliases file: alias foobar='echo bar' # this is out of my control if true; then unalias foobar echo we got inside the conditional ...
Adam Katz's user avatar
  • 4,072
0 votes
2 answers
116 views

Is it possible to use a command with an argument to trigger a bash alias?

I have a program that tries to trigger a screenlock using the following commands: xdg-screensaver lock xscreensaver -lock cinnamon-screensaver-command --lock The problem is that I'm using ...
guttermonk's user avatar
0 votes
1 answer
168 views

Zsh zinit load OhMyZsh plugin skipping aliases

I want to use these plugins using zinit to load git completions in zsh zinit wait lucid for \ OMZL::git.zsh \ OMZP::git But I don't care about the aliases, there are really too much aliases I ...
fchastanet's user avatar
0 votes
1 answer
66 views

Is there a way I can use .bash_aliases in a shell-scripts? [duplicate]

Is there a way I can use bash aliases from my .bash_aliases file within a shell-scripts? I thought of something like including source "$HOME/.bash_aliases into my script but it does not work.
nath's user avatar
  • 5,924
0 votes
1 answer
63 views

How can I call git's built-in diff command directly after configuring a different visual "git diff" substitute?

I have configured git diff to be a command that calls substitute diff for viewing file differences i.e /usr/bin/vim -dR "$2" "$3" and that doesn't work when I want to create a ...
vfclists's user avatar
  • 7,777
0 votes
1 answer
139 views

Can I reprogram the pwd command to add a trailing slash?

WHen I use the pwd command, it prints e.g /opt instead of /opt/. I would like it to print the trailing slash. However, I tried adding the following line to my ~/.bash_aliases file: alias pwd=" ...
K.defaoite's user avatar
1 vote
2 answers
368 views

alias defined in .zshrc does not propagate to shell script

I have python installed on my system as python3. In my .zshrc file I defined following alias: alias python=python3 With this, I am able to run python3 using python on the command-line: $ python ...
morpheus's user avatar
  • 115
1 vote
1 answer
163 views

How can I remove aliases "which-command=whence" and "run-help=man"?

I'm running Artix Linux and using zsh, and these two aliases return no matter how many times I unalias them or remove them from my aliasrc: run-help=man which-command=whence And they don't exist in ...
swishkin's user avatar
0 votes
1 answer
85 views

Can i used these aliases in some sort of config file?

I have many of these kinds of aliases, the part before = is the host in ssh config alias sshConfigHost='ssh -t hostname docker exec -it containerName bash' Could I add these to some sort of config ...
Nickotine's user avatar
  • 534
0 votes
1 answer
79 views

ksh88 string substitution in alias | mpv streaming [duplicate]

tl;dr how can I substitute a string (i.e. a youtube/streaming url) in an alias such as alias mpvyt='yt-dlp <URL> -o - | mpv - ' ? I live in a mezzanine studio using a M1 macbook for a ...
sylvainsab's user avatar
0 votes
1 answer
280 views

How to show help for some bash command in less (like man do) rather than print it to console

For example, there is no manual pages for trap command. Running: man trap will give: No manual entry for trap Running: trap --help will print help straight to bash console without using less like ...
Anton Samokat's user avatar
2 votes
1 answer
197 views

Converting a tcsh alias into zsh

I had a tcsh alias as follows: alias cdd 'cd `dirname \!*`' I use this to change the directory to the one containing a certain file. For instance, cdd /Users/myself/Document/Folder/File.pdf would ...
leparc's user avatar
  • 23
1 vote
1 answer
336 views

nushell - how to list aliases?

The official docs of nushell claim that one is able to list available aliases via: $nu.scope.aliases However this does not work on my Arch Linux machine: /home/rne〉pacman -Q nushell ...
Richard Neumann's user avatar
1 vote
3 answers
625 views

How to config alias on RedHat server?

I'm using a server where I'm a common user (non-sudo). I access the server through ssh. Here's the output of some commands run on the server: [username@machinename: ~]$ ps -p $$ PID TTY ...
pvti's user avatar
  • 13
0 votes
0 answers
142 views

Ubuntu WSL2 startup error "is a directory" upon adding 'alias dsa='cd /home/rj/programming' to .bashrc

I added the following alias to .bashrc alias dsa='cd /home/rj/programming/dsa' and when I type dsa in the shell, bash does indeed change to that directory but when the shell starts up I get a strange ...
lkilgoretrout's user avatar
1 vote
1 answer
477 views

Unix Command (and bash alias) or script to band/unban IP addresses in Fail2ban without having to lookup and specify "jail name"

I am creating a bash alias (or possibly a script) to ban and unban IP addresses with fail2ban on Ubuntu 20.04. The bash syntax I am using to unban IP address is: fail2ban-client set YOURJAILNAMEHERE ...
DanRan's user avatar
  • 113
-1 votes
1 answer
569 views

Sourcing alias fails - No such file or directory

I have a large number of shell scripts in a deep directory tree with varying versions. To simplify using these I added a function to create an alias (selected via command line option): function ...
symcbean's user avatar
  • 6,124
0 votes
0 answers
77 views

Bash script ignores all terminal input following an underscore [duplicate]

Goal My server manages jobs using SLURM. Each job in the queue has a job ID, which can be either a single integer or two integers separated by an underscore, e.g., 123_4. You can use scontrol show job ...
Jamin's user avatar
  • 1
0 votes
1 answer
96 views

Command doens't work when aliased

I have a command created and I am trying to convert it to an alias to make it easier to use, however I am unable to solve the problem as to how best to format it. Can you help me? The principle of the ...
vic.py's user avatar
  • 103
0 votes
1 answer
303 views

How to use alias command with a paramiko SSHClient connection?

I am trying to execute the following, with no success getting either the 'py3start' or the 'py3test' alias commands recognized - (I introduced the 'py3test' for testing purposes to check if setting ...
aeon's user avatar
  • 1
10 votes
4 answers
4k views

How can I alias `...` to `../..` in Bash?

How can I alias ... to ../.. in Bash? I am aware that other answers allow alias '...'='cd ../..' but I'd like to be able to address the directory two levels up with other commands, allowing for: cd ......
Anil's user avatar
  • 221
0 votes
1 answer
321 views

zsh: alias'd commands stop working

This keeps happening and I'm not sure why. How do I trace what zsh is actually trying to do, and why it starts ignoring my alias? ************@*******-MacBook-Pro$ reload zsh: command not found: ...
Harv's user avatar
  • 2,318
2 votes
0 answers
286 views

Order in which files within /etc/profile.d are sourced in CentOS 7.9? (for defining aliases)

I have a question related to aliases/environment variables on CentOS 7.9. I am trying to make an alias for ll with: echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z-alias-ll.sh ...
Tristan's user avatar
  • 121
2 votes
1 answer
80 views

Alias + and - in zsh?

For years I've used + and - as aliases for pushd and popd in both csh and bash. I've finally given up on my Macs and want to switch to zsh but I haven't been able to find a way to make these aliases. ...
sfjac's user avatar
  • 123
3 votes
1 answer
241 views

Prevent alias expansion when alias is passed as an argument

I have two aliases: alias rm='python my/rm/script.py ' alias docker='sudo docker ' The problem is that when running the statement $ docker rm ARGS the keyword rm is being expanded as alias and docker ...
Firelord's user avatar
  • 342
0 votes
1 answer
146 views

How to navigate to a previous line in a bash script

I have a bash script with a lot of if/elif statements. Is there a way to take the output of a command, and make it execute the associated if/elif statement, rather than the default version of the ...
Lee's user avatar
  • 117
0 votes
0 answers
48 views

How to substitute one file path for another everywhere for my profile

I am using some software on a shared Linux virtual machine, and I need to create my own version of one of the software's executable files. Let's say the executable file in question is here: $...
j_manson's user avatar
1 vote
2 answers
204 views

How I alias a hostname without root access vis-a-vis gethostbyname?

I'm running a program which does (in its source code): gethostbyname("whatever"); and I want it to use the local machine's address instead. I can't change the source. If I were root, it ...
einpoklum's user avatar
  • 10.1k
-1 votes
1 answer
332 views

Quoting arguments for alias commands. How does that work?

I added alias for my git log command: $ alias gl alias gl='gn -c git log -w -b -p --ignore-blank-lines --full-history' $ alias gn alias gn='git-number' -n flag of git-number command runs subcommand, ...
Eugen Konkov's user avatar
2 votes
1 answer
196 views

alias for watch command gets stopped?

I create this alias, so that aliases get expanded in the watch statement. > alias w='watch -x bash -i -c' > alias k=kubectl I execute it: > w 'k get pods; echo; k get svc' After two seconds ...
guettli's user avatar
  • 1,469
3 votes
1 answer
1k views

setting alias for sourcing a script, to run that script in jenkins with restricted permissions

I want to run source ./script_name instead of ./script_name. Can I create an alias for this ? The Jenkins job will run the script as ./script_name and I can't edit the way it will run the script on ...
Anubhav Rai's user avatar
0 votes
1 answer
199 views

Alias for the "su" Command

BASH SHELL; DEBIAN STRETCH As seen here, I've created a "seems to work OK, most of the time" alias function for the su command (actually, I'm not able to find any problems with it...yet). I'...
Digger's user avatar
  • 405
0 votes
1 answer
4k views

tilde_expand: No such user .ssh

I have this weirdest error where a single IP address with ssh would immediately return an error arthur@arthur-laptop:~$ ssh 192.168.1.85 tilde_expand: No such user .ssh I feel like it's an issue with ...
Arthur Attout's user avatar
0 votes
0 answers
55 views

How openbox knows .bash_aliases used in its autostart file

I'm using two commands in a file executed by my .config/openbox/autostart.sh which are also aliased in my .bash_alises and one of them changes from time to time. The thing is that I also use these ...
muggi's user avatar
  • 749
2 votes
1 answer
254 views

bashrc alias using ticks and backticks not working

I would like to create in .bashrc an alias which executes the following: virsh list --all | sed '1,2d' | sed '/^$/d'| awk '{print $2" state:"$3" "$4}' I've tried in different ways ...
Marius Ardelean's user avatar
0 votes
1 answer
554 views

How to list only the aliases defined by the user?

I'm using the ZSH and defined some aliases (stored in multiple fines, that are loaded in the ~/.zshrc). That is working fine. Executing the command alias allows to list all available aliases. Now I'd ...
automatix's user avatar
  • 217

1
2 3 4 5
19