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.
164 questions
442
votes
16
answers
90k
views
In Bash, when to alias, when to script and when to write a function?
Noone should need 10 years for asking this question, like I did. If I were just starting out with Linux, I'd want to know: When to alias, when to script and when to write a function?
Where aliases are ...
145
votes
6
answers
180k
views
How to pass parameters to an alias?
For bash script, I can use "$@" to access arguments. What's the equivalent when I use an alias?
134
votes
36
answers
76k
views
Quick directory navigation in the bash shell
I would like to frequently switch between directories that are in totally unrelated paths, for example /Project/Warnest/docs/ and ~/Dropbox/Projects/ds/test/.
But I don't want to type cd /[full-path]/...
355
votes
5
answers
305k
views
Why doesn't my Bash script recognize aliases?
In my ~/.bashrc file reside two definitions:
commandA, which is an alias to a longer path
commandB, which is an alias to a Bash script
I want to process the same file with these two commands, so I ...
108
votes
7
answers
40k
views
How to use `which` on an aliased command?
Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance,
alias vim='vim -X'
alias grep='grep -E'
alias ls='ls -G'
The problem is ...
326
votes
25
answers
284k
views
How to have tail -f show colored output
I'd like to be able to tail the output of a server log file that has messages like:
INFO
SEVERE
etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I setup ...
225
votes
9
answers
58k
views
Run a command that is shadowed by an alias
Let's say I have the following alias in bash - alias ls='ls --color=auto' - and I want to call ordinary ls without options. Is the only way to do that is to unalias, do the command and then alias ...
64
votes
6
answers
49k
views
How can I `alias sudo !!`?
I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints
sudo: !!: command not found
If I use double quotes, it substitutes the ...
36
votes
4
answers
20k
views
Why does sudo ignore aliases?
I am running Ubuntu 10.04 and I use upstart for daemon management. My enterprise application is run as a daemon and must be run as root because of various privileges. E.g.:
sudo start my-...
142
votes
10
answers
66k
views
How do I get bash completion for command aliases?
I am looking to get tab-completion on my command line aliases, for example, say I defined the following alias :
alias apt-inst='sudo aptitude install'
Is there a way to get the completions provided ...
44
votes
1
answer
13k
views
Aliases vs functions vs scripts [duplicate]
This site says, "Shell functions are faster [than aliases]. Aliases are looked up after functions and thus resolving is slower. While aliases are easier to understand, shell functions are preferred ...
3
votes
3
answers
1k
views
Why doesn't my command work when aliased?
I use ps -ef | grep catalina | grep -v grep to print the tomcat process running on the system:
kshitiz 7099 1 0 May11 ? 00:02:29 /usr/lib/jvm/jdk1.8.0/bin/java -agentlib:jdwp=transport=...
31
votes
9
answers
26k
views
How to set an alias on a per-directory basis?
Suppose you have an alias go, but want it to do different things in different directories?
In one directory it should run cmd1, but in another directory it should run cmd2
By the way, I have an ...
30
votes
3
answers
34k
views
Escaping quotes in zsh alias
Following on from this question about stripping newlines out of text, I want to turn this into a zsh alias as follows:
alias striplines=' awk " /^$/ {print \"\n\"; } /./ {printf( \" %s \",$0);}"'
I'...
11
votes
3
answers
9k
views
Single or Double quotes when defining an alias?
I know that contents of double quotes are expanded, whereas the contents of single quotes are not, such that
echo '$1'
gives
$1
where as
echo "$1"
gives
<the argument - blank in this ...