Node:Alias examples, Up:Aliases
Alias examples
alias ls "ls -F --color"
- Override the command
ls
to be expanded tols -F --color
. Any arguments given to the newls
alias will be appended. alias ll "ls -l"
ll
will be expanded tols -l
, regardless if there is an alias for plainls
like the one above. Aliases can't be nested.alias ls list
- Override the command
ls
to be expanded to the commandlist
. This is fine, but will generate a warning;warning: alias 'ls' shadows a command with the same name
, because the original commandls
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 pagerless
. The%1
keyword is replaced with the first argument topls
, any other arguments will be appended at the end (to the localless
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 topls
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.