Last Updated: May 27, 2020
·
2.119K
· lxe

Save time typing paths with Autojump: arguably the most important shell tool.

Autojump is a way to navigate directory paths using fuzzy and intelligent search.

I started using about 4 years ago, and it have probably saved an entire month of my time typing cd paths. It's my #1 recommended shell tool. Here's a scenario:

Without autojump:

# Let's start working on a project
cd ~/devel/work/backends/project1
vim .

# Hmm.. we need to edit some module feature
cd node_modules/fancy_module/lib/feature
vim file.js

# Aah... gotta edit my nginx config
cd /etc/nginx/sites_available/
vim my-site.conf

# Back to the project....
cd ~/devel/work/backends/project1

With autojump:

# Let's start working on a project
j pro
vim .

# Hmm.. we need to edit some module feature
j fan lib
vim file.js

# Aah... gotta edit my nginx config
j si a
vim my-site.conf

# Back to the project....
j pro

As you can see, I don't even have to remember the full name of the path with autojump (the j command). I just need to remember some parts of the name, and autojump auto-jumps you to a location based on how much time you've spent there, and how long ago you've accessed it (or probably using some kind of mind-reading magic).

This tool is an absolute must-have for anyone who spends their days in a terminal.

To install on OSX:

brew install autojump && echo \
  '[[ -s `brew --prefix`/etc/autojump.sh ]] && . `brew --prefix`/etc/autojump.sh' >> \
  $(ls ~/.bash_profile 2>/dev/null || ls ~/.zshrc)

An example to get started:

mkdir test-dir another-dir
cd test-dir
cd ../another-dir
j test
j another

9 Responses
Add your response

'll take a look into this. Thanks for the tip!

over 1 year ago ·

Another alternative is the 'z' command :)

over 1 year ago ·
over 1 year ago ·

Been using z.sh for this, too. Huge timesavers!

over 1 year ago ·

I rolled a simpler, more specific solution that I still use:

# quickly jump to a project
prj() { cd "$HOME/projects/${*}"; }
over 1 year ago ·

@astropanic fasd looks too hardcore to me :)

over 1 year ago ·

@dpashkevich it allows you to lazy switch directories and opening files too, look at the examples :)

over 1 year ago ·

@astropanic I know, but I think something like v def conf is way too cryptic

over 1 year ago ·

thx, using from now on

over 1 year ago ·