Autojump is a way to navigate the filesystem faster. It works by maintaining a database of directories you commonly
cd into. Once you’ve visited a directory, you can return to it via the autojump shortcut, saving having to type or complete the full path.
$ cd /foo $ cd ~ $ j foo $ pwd /foo
Here we change into the
/foo directory and then into our home directory. We then run the autojump convenience shortcut,
j, and return to the
Installing autojump 🔗︎
Autojump require Python 2.7+ and ships with most of the major distributions, for example on Ubuntu.
$ sudo apt install autojump
Or on OS X via Homebrew.
$ brew install autojump
It supports most of the major shells, Bash, Zsh, Fish, etc and needs to be sourced by your shell before it’ll function. For Fish I would add this to my configuration.
begin set --local AUTOJUMP_PATH /usr/share/autojump/autojump.fish if test -e $AUTOJUMP_PATH source $AUTOJUMP_PATH end end
And then source it manually or launch a new shell to automatically source it.
Using autojump 🔗︎
We’ve already seen autojump’s basic mode, returning to a previously visited directory. In addition to changing to a directory we can also change to a child directory of the current directory, using
$ j foo $ jc bar
We can open our default file manager in the path requested too, using the
$ jo foo
Or to a child directory.
$ jco bar
Autojump maintains a weighted database of directory entries, so if you have a name collision, then you can narrow it down by specifying further directory information.
TIP   You can see the database via the
j --stat command. You can also manually add directories or change weights if needed, see
j --help for options.
Let’s say you have
/home/james_work/src/ in your database like so:
30 /home/james/src 10 /home/james_work/src
j autojump would leap into the higher weighted directory,
/home/james/src/, but if we want the lower weighted directory we can type:
$ j w src
And you’ll jet off to the lower weighted:
As always, hope someone finds this useful!