Linux Directory-jumping Hack
For developers, it’s kind of common to jump between directories whilie implementing multiple source codes at a time. This is why many developers (on the Linux system) uses terminal multiplexers like tmux or screen to enumerate multiple environments at a time, but the problem still lingers when it comes to the directories that are not always but frequently visited. Isn’t it too much to make separate windows just to leave those three or four not-always-but-frequently-visited directories opened?
Today I managed to come up with my own solution. I made a goto command for my Bash shell. (Put these lines at the end of your bash configure file, for example, .bash_profile or .bashrc)
function goto() { eval X=\${$1}; cd $X; }
export mfd=“~/my/favorite/directory”
This command simply changes the current directory to the directory, that is pre-defined with a nickname. For example, I can jump to “~/my/favorite/directory” from anywhere, simply by typing the command below:
Now I’m using it to jump between the root directory of my source tree and the build directory. Both directories are not always used, but frequently visited during the building and debugging stage. I think there must be some more decent utilities for this kind of problems, but this is enough for me. Plus, it’s free from any additional installation!