A blog dedicated to text editing and general exploration of computing knowledge
Friday, November 13, 2009
Last Directory Visited
From the shell, typing "cd -" will take you to the last directory visited. This is useful from a command-line navigation perspective and from inside of shell scripts as well.
5 comments:
Philipp
said...
Of course, this works in the VIM command-line as well:
Don't forget about pushd and popd. pushd works just like cd but puts your current directory onto a stack. popd removes the directory from the top of the stack and cds into it.
5 comments:
Of course, this works in the VIM command-line as well:
:cd /tmp
:cd -
[...] and from inside of shell scripts as well.
In shell script, I find it cleaner to do cd in a subshell so that the old dir is automatically restored.
# commands in olddir
( cd newdir
# commands in newdir
)
# commands in olddir
Don't forget about pushd and popd. pushd works just like cd but puts your current directory onto a stack. popd removes the directory from the top of the stack and cds into it.
This was a pretty mundane bash tip, and not really a vim tip ... But pushd and popd were new to me! Thanks!
@Spug
Yeah, sorry, they can't all be exciting.
pushd and popd were covered in a previous post:
http://dailyvim.blogspot.com/2008/06/pushd-popd.html
Post a Comment