Wednesday, August 11, 2010

bash: little-known alias trick

According to the bash manual:
If the last character of the alias value is a space or tab character, then the next command word following the alias is also checked for alias expansion.
By default, alias expansion is not performed in a non-interactive shell (unless 'shopt expand_aliases').  Besides, if you are using ssh, the account on the server might not have all the aliases you are used to.  The trick is to alias ssh with an extra space.

$ alias ll="ls -al"
$ alias s="ssh me@mymachine.com "
$ s ll
(long listing of all files...)

No comments:

Post a Comment