Introduction

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:

The problem

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 and 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 ../../.."

Then there’s goto.

Installation

Installation is easy, instructions can be found in the project’s repository https://github.com/iridakos/goto. There are three ways to install it:

  1. Download goto.sh and save it somewhere, for example in ~/bin, then load in your bash profile with source ~/bin/goto.sh
  2. … or clone the repo and run install script
  3. … or install with brew install goto

Restart the terminal and check whether goto works, by running

goto -v

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:

  • c for my cloud drive folder
  • d for downloads folder
  • t for temp folder
  • sc for my current work project called StellaControl
  • w for my work projects folder

Navigating

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 goto -l.

To reduce the amount of typing even more, I’ve defined in my bash profile a short alias g for my goto command:

alias g=goto

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 goto does!