Node:Alias examples, Up:Aliases



Alias examples


alias ls "ls -F --color"
Override the command ls to be expanded to ls -F --color. Any arguments given to the new ls alias will be appended.
alias ll "ls -l"
ll will be expanded to ls -l, regardless if there is an alias for plain ls like the one above. Aliases can't be nested.
alias ls list
Override the command ls to be expanded to the command list. This is fine, but will generate a warning; warning: alias 'ls' shadows a command with the same name, because the original command ls is lost and can't be referenced (except through another alias.)
alias pls "ls %1 | less"
Create a new command pls, which lists the contents of a directory and pages it through the pager less. The %1 keyword is replaced with the first argument to pls, any other arguments will be appended at the end (to the local less command.)
alias pls "ls %* | $PAGER"
Create a new command pls, which lists the contents of a directory and pages it through your favourite pager. Any arguments given to pls will be inserted between ls and the pipe because of the %* keyword. Using $PAGER is fine, it is expanded by the ordinary shell.
alias rels "cache --touch %*; ls -F --color %*"
Create a new command rels, which flushes the directories from the cache before listing them. Two %* sequences are needed to insert the arguments at both places.