pushd and popd
April 25, 2008
It's amazing how one can keep on learning new bash tricks year after year. Today's candy is a pair of bash builtins: pushd and popd. pushd pushes a path on a stack, and popd pops the latest stacked path from the stack and does a cd to it.
Extremly useful!
Still, writing "pushd `pwd`" each time I want to save my location is a bit too much work, so I added 2 aliases to my bash config:
alias po='popd'
alias pu='pushd `pwd`'
Example:
[HEAD] ~/test/Module> !301$ pu
~/test/Module ~/test/Module
[HEAD] ~/test/Module> !302$ cd
[HEAD] ~> !303$ po
~/test/Module
[HEAD] ~/test/Module> !304$
Extremly useful!
Still, writing "pushd `pwd`" each time I want to save my location is a bit too much work, so I added 2 aliases to my bash config:
alias po='popd'
alias pu='pushd `pwd`'
Example:
[HEAD] ~/test/Module> !301$ pu
~/test/Module ~/test/Module
[HEAD] ~/test/Module> !302$ cd
[HEAD] ~> !303$ po
~/test/Module
[HEAD] ~/test/Module> !304$