Terminal: remember working directory

Make yourself some symbolic links in your home directory:

ln -s /opt/really/long/obnoxiously/long/path/to/some/projectname

This command will make a link called projectname in your home directory into which you can cd, and everything will work perfectly.


z is a very nice "plugin" for bash or zsh (it's included in Oh My Zsh) which keeps track of directories you cd to, and allows you to quickly switch to directories using parts of their names, based on how frequently you use them.

So after a little while, it will know that

z git-repo

should cd to the git-repo directory you use most often. You can qualify that with part of the path, e.g.

z d git-repo

or even

z d git

I've found this to be more useful than aliases or even CDPATH because it learns on its own and adapts to my changing habits.


Once inside the directory, you do:

repo=`pwd`

and later you do

cd $repo

If you want to keep it for next time, you could do:

echo "export repo=`pwd`" >> ~/.profile

Tags:

Terminal