I am writing about tools I use regularly use, to make my workflow efficient. My last post was about powerline
. Today's post is about autojump
that lets you navigate your filesystem with very few keystrokes.
autojump provides a very easy way to navigate your filesystem from within the comforts of your terminal app.
autojump
maintains a database of all the directories you visit by assigning weights to each path. The most frequently used path has a higher weight .
On subsequent accesses to the same directory, you can do a j <destination directory name>
without having to specify the entire path to your destination. j
here is a wrapper over autojump
that lets you forget that you need to cd
to a directory ever.
I find myself using j
a lot, especially in maven projects where the directory of your interest is buried deep in the hierarchy of src > main > java > ...
There is another cool feature of j
that I use a lot. If you do a jo <directory name>
, instead of jumping to the directory, your destination directory gets opened in the file explorer window like so:
There are other features that I seldom use but cool nevertheless. jco
lets to navigate to a child directory the file explorer view and jc
jumps to a child directory.
You can also purge non-existent paths with a autojump --purge
. This is useful when you have deleted some heavily used directories and would like to clear up the autojump
database. Personally, I would have liked the purge to happen when the directory gets deleted instead of putting the onus on me. Something like a LRU list comes to mind.
The weights are visible when you do a autojump --stat
like so:
The autojump
weights can be manually decreased or increased if you want to force autojump
to go to a preferred path. I personally have never done this except perhaps when I was exploring the different options.
All said, autojump
is a very useful utility to have in your terminal that will save you a lot of time. Here's how you can set it up:
- Install
autojump
with brew:
brew install autojump
- Then source this script inside your
.bash_profile
:
#Source Autojump
[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh
That's how simple it is!