Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nepsilon/39d2ca784343f3be0331059f5728b3d6 to your computer and use it in GitHub Desktop.
Save nepsilon/39d2ca784343f3be0331059f5728b3d6 to your computer and use it in GitHub Desktop.
Pruning your Bash history for a better search experience — First published in fullweb.io issue #94

Pruning your Bash history for a better Ctrl+R experience

If you are accustomed (like me) to fire Ctrl+R before running any new command, here is a tip to keep your Shell history clean and more search-friendly.

The best way to do this is to prevent some commands (e.g. those with passwords inlined) to be logged, but also to skip saving duplicated commands.

This is all controlled by the environment variable HISTCONTROL. It can take 3 values:

  • ignorespace: lines which begin with a space character are not saved
  • ignoredups: lines matching the previous history entry are not saved
  • ignoreboth: is shorthand for ignorespace and ignoredups

I recommend using ignoreboth. One set, just start your commands with a space will to skip the shell history log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment