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
Written by Aleksey Smolenchuk
Related protips
9 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/97226/78ac7450752d7b4882df4c6e53e230db.jpg)
'll take a look into this. Thanks for the tip!
Another alternative is the 'z' command :)
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/6592/2353857b3f577eb4e3840111ca9a7ecb.jpeg)
hmmm... https://github.com/clvv/fasd anyone ?
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/107066/9927dee057194c0727faed318c91514e.jpeg)
Been using z.sh for this, too. Huge timesavers!
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44093/d42a7264714dee5006b9c99d2567a320.jpeg)
I rolled a simpler, more specific solution that I still use:
# quickly jump to a project
prj() { cd "$HOME/projects/${*}"; }
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44093/d42a7264714dee5006b9c99d2567a320.jpeg)
@astropanic fasd looks too hardcore to me :)
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/6592/2353857b3f577eb4e3840111ca9a7ecb.jpeg)
@dpashkevich it allows you to lazy switch directories and opening files too, look at the examples :)
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44093/d42a7264714dee5006b9c99d2567a320.jpeg)
@astropanic I know, but I think something like v def conf
is way too cryptic
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/83059/aee7eabef46c69a79d95081ee6946389.jpeg)
thx, using from now on