GOTO has been considered harmful ever since E.W.Dijkstra told us so ;-) But there’s one
goto which is actually very useful! It’s a shell utility for bookmarking frequently visited folders, which I’ve been using since a long time. It can be found at https://github.com/iridakos/goto.
To get the idea, watch
goto in action:
I spend a lot of time in terminal, constantly navigating between many folders. Mostly the same folders - my current project, temp folder, downloads, photos, music etc. It’s
cd all the time, too much typing, even with tab completion. Just do the math! 500 excessive keystrokes a day, times 250ms spent on a single keystroke, times 220 work days divided by 3600 seconds/hour gives us … Nearly 8 hours lost each year! 40 work days lost during your professional lifetime on
cd. There must be a better way.
My first life-saver is
cd -. It teleports me back to the previous folder where I was. And back. And back again. Then I have my handy aliases in bash profile for going up:
alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.."
Installation is easy, instructions can be found in the project’s repository https://github.com/iridakos/goto. There are three ways to install it:
- Download goto.sh and save it somewhere, for example in
~/bin, then load in your bash profile with
- … or clone the repo and run
- … or install with
brew install goto
Restart the terminal and check whether
goto works, by running
Creating folder aliases
First we need to create aliases for most-often used folders. For example, to register
~/projects/work folder under
work alias, run:
goto -r work ~/projects/work/
The shorter the alias, the better. I use a single-character alias for most frequently used locations:
cfor my cloud drive folder
dfor downloads folder
tfor temp folder
scfor my current work project called StellaControl
wfor my work projects folder
Now that you have the aliases, life is easy. To navigate to the above locations, you type:
goto t goto w goto c
If you forget your aliases during first days of use, use
tab completion or run
To reduce the amount of typing even more, I’ve defined in my bash profile a short alias
g for my
Now, to navigate to temp, work or cloud folders all we need to do is this:
g t g w g c
Sweet. Another 12 hours a year saved.
Have fun with terminal!
What about ZSH?
There is a similar utility for
zsh, named Warp Directory, found here: https://github.com/mfaerevaag/wd. It does exactly what
Author Tomasz Waraksa
© Tomasz Waraksa, letsdebug.it
This article is not promoting any of the described products, services or vendors. We don't have any commercial interest nor associations with them. We're not trying to suggest that these products or services are best for you, nor promising that your experience will be the same.
In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website and any information presented on it.
Through this website you are able to link to other websites which are not under our control. We have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them.
Permission is hereby granted, free of charge, to any person obtaining a copy of software published on this website and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions, unless stated explicitly otherwise:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The software is provided “as is”, without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.