Although pushd and popd are intended mainly for programming, they fill a nice niche when navigating directory structures. If you're current working directory is some deeply nested location like /home/travis/src/myprojects/vim-patch/includes and you need to cd into /tmp for a bit but know you'll be coming back to the original directory, you should use pushd rather than cd. pushd takes the current directory and pushes it into a stack. popd pops the top directory off the stack and does an automatic cd into it. For example:
travis@travis-ubuntu:/usr/share/vim/vim71/colors% pushd /tmp
/tmp /usr/share/vim/vim71/colors
travis@travis-ubuntu:/tmp% popd
/usr/share/vim/vim71/colors
travis@travis-ubuntu:/usr/share/vim/vim71/colors%
Subscribe to:
Post Comments (Atom)
1 comment:
pushd and popd is more powerful because it supports more directories in the stack, but I usually use "cd -" or "cd $OLDPWD" (which is the same).
Post a Comment