aliases [was: Change Directory with two dots (cd..)]

Francisco Borges f.borges at rug.nl
Wed Apr 26 12:10:40 UTC 2006


ยป On Wed, Apr 26, 2006 at 11:58AM +0100, Daniel Carrera wrote:

> Francisco Borges wrote:
> >Get serious:
> >
> >alias ..="cd .."
> >alias ...="cd ../.."
> >alias ....="cd ../../.."
> >alias .....="cd ../../../.."
> >
> >;-)
>
> I've done that, except I use commas. It's marginally easier (one less
> keystroke and uses a stronger finger) and doesn't present problems with
> the path ../

Having an alias with .. doesn't interfere with the path ;-)

> alias ,='cd ..'
> alias ,,='cd ../..'

> You know what would be cool? If you could define recursive aliases:
>
> alias ,='cd ..'
> alias ,,='cd ..; ,'

You can have recursive aliases (for sure in zsh, tcsh, bash). I've been
using it for years.

In zsh you can have global aliases, which expand regardless of the
position like;

#--------------------------
# Global aliases - Don't not have to be at the beginning of the command
# line.
alias -g M='|$PAGER'
alias -g H='|head'
alias -g T='|tail'
alias -g N='&>/dev/null&'
alias -g G='|grep'
alias -g U='|uniq'
alias -g W='|wc -l'
alias -g S='|sort'
#--------------------------

with these you can do:

% dlocate -l aspell G "^ii"
% locate emacs G png G icon

-- 
Francisco





More information about the ubuntu-users mailing list