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