I’m doing Blogvent, a challenge to blog every day in December. Today’s prompt is:
Day 2: Your favorite CLI utility. Highlight a terminal tool (like
fzf,ripgrep,jq, orbat) and one flag you use constantly.
Note: You can see what I plan to write about each day in the list of prompts.
A utility I cherish is Autojump. Think of
it like a much more powerful version of cd.
I installed it via Homebrew:
$ brew install autojump
Once initialized, it’s exposed by a function named j.
After you’ve visited a directory once, Autojump adds that directory to its
weighting system, which you can inspect with --stat.
$ j --stat | tail
93.3: /Users/me/code/company-projects
94.9: /Users/me/code/jakeworth-hugo
133.0: /Users/me/code
________________________________________
3448: total weight
176: number of entries
94.87: current directory weight
data: /Users/me/Library/autojump/autojump.txt
When you type j followed by a directory name, it will jump to the strongest
weighted match. For example, ~/code is a directory I frequent, so it’s highly
weighted, and this works:
$ j code
/Users/me/code
I seldom use cd outside of a single project. Instead, I type j followed by
til or dotfiles and jump there.
For those who haven’t experienced the power of this tool, my advice is to try
it. Meanwhile, let me address a fair counterargument: “Why not use cd?” I
offer two answers.
First, career programming is a game of keystrokes, where fewer is better.
j meetups is eight fewer keystrokes than cd ~/code/meetups. Your hands will
thank you.
Second, many programmers struggle with traversing their filesystem, and this
simplifies that. Going from ~/code/company/frontend to ~/code/dotfiles by
typing cd ../../dotfiles is awkward, and also not that interesting. I’d prefer
to take a shortcut.
- Autojump – GitHub repository