Alias (command)
From FreeBSDwiki
(Difference between revisions)
(Speab about reading alias values) |
(Complete some missing informaitons) |
||
Line 1: | Line 1: | ||
The [[alias]] command is used to create [[aliases]], and to get a list of aliased commands. | The [[alias]] command is used to create [[aliases]], and to get a list of aliased commands. | ||
− | ==Aliases | + | ==Aliases creation== |
The syntax if shell dependant: | The syntax if shell dependant: | ||
− | '''B-Shell''' ([[sh]], [[bash]]) : | + | '''B-Shell''' ([[sh]], [[bash]]) and '''Z-Shell''' ([[zsh]]) : |
alias l=ls | alias l=ls | ||
alias la='ls -A' | alias la='ls -A' | ||
Line 12: | Line 12: | ||
alias l ls | alias l ls | ||
alias la 'ls -A' | alias la 'ls -A' | ||
+ | |||
+ | ==Special functions== | ||
+ | |||
+ | Some shells provides additionnal features, such as the '''-g''' argument of [[zsh]]'s alias [[builtin command]]. This allow creation of ''global aliases'' : | ||
+ | '''> alias a=aaa''' | ||
+ | '''> alias -g b=bbb''' | ||
+ | '''> echo a b''' | ||
+ | a bbb | ||
+ | This can be very useful : | ||
+ | '''> alias -g ...='../..'''' | ||
+ | '''> pwd''' | ||
+ | /foo/bar/misc | ||
+ | '''> cd ...''' | ||
+ | '''> pwd''' | ||
+ | /foo | ||
+ | |||
+ | For more informations on the specific options of your shell, have a look to it's man page. | ||
==Aliases consultation== | ==Aliases consultation== |
Revision as of 17:15, 14 July 2005
The alias command is used to create aliases, and to get a list of aliased commands.
Aliases creation
The syntax if shell dependant:
B-Shell (sh, bash) and Z-Shell (zsh) :
alias l=ls alias la='ls -A'
alias l ls alias la 'ls -A'
Special functions
Some shells provides additionnal features, such as the -g argument of zsh's alias builtin command. This allow creation of global aliases :
> alias a=aaa > alias -g b=bbb > echo a b a bbb
This can be very useful :
> alias -g ...='../..' > pwd /foo/bar/misc > cd ... > pwd /foo
For more informations on the specific options of your shell, have a look to it's man page.
Aliases consultation
You can use this to get an existing aliases list:
> alias ...=../.. ....=../../.. .....=../../../.. ......=../../../../.. .......=../../../../../.. clean='rm -f `find . -name "*~" -o -name ".*~" -o -name ".*.core" -o -name "*.core" -o -name "#*#" -o -name "a.out"` close='cdcontrol -f /dev/cd0 close' eject='cdcontrol -f /dev/cd0 eject' fr='export LANG=fr_FR.ISO8859-15' la='ls -a' ll='ls -Al' ls='ls -FG' > alias ls ls='ls -FG'