Pragmatism in the real world

Autojump is magic

One of my favourite command line utilities is autojump. It’s a small command line utility that allows you to change directory without having to remember exactly where that directory is.

For example, to start working on OpenWhisk, I simply type:

j openw

And the current directory is changed to /Users/rob/Projects/openwhisk/incuator-openwhisk for me.

This is much easier than typing cd ~/Pro{tab}op{tab}in{return}!

Biasing towards a particular directory

When you have a directory that’s a common one that you always want to get to first, you can bias autojump to find it. I use this for j 2018 which I always want to select the directory where my talks are at ~/Dropbox/Presentations/2018 (this year) rather than one of the many other 2018 directories on my system such as ~/19FT/Accounts/2018 and ~/19FT/Contracts/2018, etc.

To do bias a directory, change to it and then type:

j -i 9999 .

This increases the weight of this directory in autojump’s list by an additional 9999 which then makes it the most important one.

Install it

It’s available for macOS via Homebrew (brew install autojump) and Linux (apt-get install autojump, yum install autojump) and can probably be built for every other *nix. It even works on Windows, so there’s no excuse for not making directory navigation that much easier!

2 thoughts on “Autojump is magic

  1. Thanks for this Rob!

    I've been using 'z' for this function, but haven't been tickled, so will try autojump.

    Here are two for you:

    1) shopt -s autocd (new to me after 18+ years of bash)
    2) https://github.com/junegunn/fzf#fuzzy-completion-for-bash-and-zsh

    The first lets you just type the subdir name – sure, only saving two keystrokes over autojump, but perhaps useful if you log into other systems and don't want to set up autojump.

    The second takes a bit to wrap your head around but is one of those use-it-every-day-after sorts of tools.

Comments are closed.