Skip to content

Supercharged Zsh Command History

Tags: coding, learning, productivity, software • Categories: Productivity

Table of Contents

I’m a big fan of incrementally improving your terminal productivity. I invested in learning tmux a while back and it’s been a game-changer for me in terms of flying through terminal workflows (which is especially important for me since I’m heavily REPL-driven).

I’ve wanted to improve my terminal history functionality for a while now and recently found the time to tune up this part of my dev workflow!

Fzf-based Shell History

I’ve been using fzf based completion for years and it’s awesome. It’s easy to install so if you want something better than the default, this is a great place to start.

Removing Entries from ZSH History

If you update HISTORY_IGNORE your existing history is not retroactively filtered. In order to strip out old entries, run the following command:

LC_ALL=C sed -i '' '/sudo hostile.*/d' $HISTFILE

Atuin Shell History

I was hesitant to use Atuin for a couple of reasons:

  • It’s fuzzy finder is custom and I like fzf and have it heavily customized
  • The main value prop is shell history syncing, which I don’t much care about
  • Other solutions seemed more simple, and simple systems are always better.

However, I started hitting the zsh history limit and losing important commands that I didn’t want to have to remember, so the sqlite-backed nature of Atuin and other "advanced zsh history managers" became more interesting.

I tried a couple of other solutions, and they were all either abandoned or missing some obvious features (like multiline shell history).

Also, I discovered some other great features:

  • Regex support via r/search/ syntax
  • Ability to filter searches based on host and directory
  • Exit code and usage monitoring to help prioritize results
  • Buffer text is automatically defaulted to the search contents
  • Automatic integration with zsh-autosuggest
  • Copy selection to clipboard (I was worried about losing this)
  • Thoughtful keyboard shortcuts

I wrote a simple zsh plugin to make the installation a bit more seamless.

Here are a couple issues I ran into:

Importing Multiple History Files

I backed up my zsh history to an extra file a couple of times because entries started getting dropped from my main history.

You can import any additional files into atuin by modifying the history file reference:

HISTFILE=~/zsh_history_backup atuin import zsh

Alternatives

Here are some alternatives I looked at:

Conclusion

Leveling up your terminal productivity is always a good move, and tools like fzf and Atuin can make a big difference. While I’ve relied on fzf for years, Atuin has been a great addition to my toolbox with its sqlite-backed history and handy features like regex searching and filtering by directory. Despite a few issues like noisy results and some missing keybindings, it’s still a solid option for those hitting the limits of basic shell history. Alternatives like McFly looked promising but fell short, especially without multiline support. At the end of the day, adding tools like fzf and Atuinto your terminal will improve your workflow and productivity.

Keep in Touch

Subscribe to my email list to keep in touch. I’ll send you new blog posts and other thoughts.