Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
Last active November 6, 2022 10:33
Show Gist options
  • Select an option

  • Save barbietunnie/b1c50fa9dc2622f2e8e433766e7cc6b5 to your computer and use it in GitHub Desktop.

Select an option

Save barbietunnie/b1c50fa9dc2622f2e8e433766e7cc6b5 to your computer and use it in GitHub Desktop.
Managing shell history with `historian`

Managing shell history with historian

historian is a command-line utility for managing shell history using an SQLite database.

~/.bash_history is deduped and imported into a database.

Setup

  1. Add to PATH

    export PATH="$PATH:/Users/jerry/historian"
    
    

    Alternatively, you can set up an alias for it

    alias hist="/Users/jerry/historian/hist"
    
  2. Add hist import to your .profile (assuming hist is already in your path):

    echo hist import >> ~/.profile
    

    This will import your .bash_history every time you launch a new shell.

Other commands:

  1. Show config

    hist config
    
  2. Search (detailed)

    hist search nvm
    
  3. Search (shorthand)

    hist /nvm
    
  4. View log

    hist log
    

Pitfalls

  • Live like your db file could be corrupted at any time.
  • Be careful of running specially crafted hist commands against ~/.bash_history files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment