Thursday, February 01, 2007

My favourite Bash trick

In celebration of finally glimpsing Comet McNaught last night (now extremely faint) after weeks of seeing only clouds I'll share with you my favourite Bash shell trick (okay, so I couldn't think of a way to tie the two together)

a() { alias $1=cd\ $PWD; }

Pushd, popd and cdpath allow you more flexibility to move around directories as long as your movements are stack-like (stacked?). But with the above definition you can remember your current directory by typing "a 1". Move somewhere else and type "a 2" and so on. Later just enter "1" and you will switch back to the first directory.

I usually find myself needing more freedom than a stack.

Labels: