AutoJump: CD that Learns

The zsh plugin that’s saved me the maximum amount of heartache has to be autojump and the number of folks I tell about it that have never heard of it blows my mind.

Everyone has some massive repository or deep directory tree that they have to navigate regularly. And while most of us can type pretty quickly and there are ways to get into subdirectories fast, why not have something that just knows where you’ve been most often and takes you there?

That’s what it does, basically.

Once you’ve installed it (brew install autojump) loaded up with your shell (add it to ~/.zshrc in your plugins array if you’re using oh-my-zsh), it just starts working. Move around your directory tree like you normally do and once you’ve been somewhere once, you can hop directly back there with j directory.

Here’s an example:

There are two store directories that I’m constantly in. One of them is deep deep in some front-end code and the other is just a few directories away from my home. But in either, case, I can type j store and wind up in the one that I visit most often. If it picked the wrong one, I can just run the same command again and it’ll go to the second-most-often visited path with that name. If I know ahead of time that there are going to be duplicates I can offer that too with j console store and skip the double run of the command.

Stop navigating to directories by hand. Your fingers don’t need that kind of mileage.