Node:Alias examples, Up:Aliases
Alias examples
alias ls "ls -F --color"- Override the command
lsto be expanded tols -F --color. Any arguments given to the newlsalias will be appended. alias ll "ls -l"llwill be expanded tols -l, regardless if there is an alias for plainlslike the one above. Aliases can't be nested.alias ls list- Override the command
lsto 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 commandlsis 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%1keyword is replaced with the first argument topls, any other arguments will be appended at the end (to the locallesscommand.) 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 toplswill be inserted between ls and the pipe because of the%*keyword. Using$PAGERis 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.