Skip to content

svanellewee/historian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Historian

This aims to be a more powerful way of storing your bash (zsh?) history.

Current goals:

  • Per directory command history
    • A global command history dump still needs to be implemented
    • A dump for specific days needs to be added.
  • A transferrable history database that can stay with you long after you've moved laptops.
  • Something that will not get confused by multiple tmux/terminal sessions.
  • Allow annotation additions to history entries (ie These commands were part of JIRA ticket this or that)
  • Searchable using a proper search system (Bleve?)
    • I'd like to get rid of history | grep ...

Installation

go get github.com/svanellewee/historian

How to use this

Add something like this to your bashrc

# Taken from https://www.digitalocean.com/community/tutorials/how-to-use-bash-history-commands-and-expansions-on-a-linux-vps
HISTSIZE=5000
HISTFILESIZE=10000
function history-store() {
    echo "$(history 1)" >> "${OUTPUT_FILE}"
    historian insert "$(history 1)"
}
alias hlist="historian last"

# The secret sauce that makes things work...
export PROMPT_COMMAND="history-store"

Last

To see the last 10 commands used inside the current directory, run

historian last 10

Today

To see all the commands you ran and at what times and where for today just ask:

historian today

This will give you a sorted list, so you can see what you did. Might be useful for timesheet-y type applications. (Mmmm perhaps I need a sprint command as well)

Search

Go's regex are used here. Examples:

  • Where did you mispell PATH?
historian search PAHT
  • If you write nothing it matches all...probably a bad idea
historian search
  • You need to find all calls with bind and/or shutdown
historian search 'bind|shutdown'
  • You wrote this dumb history app called historian and now need to write examples for the docs:
historian search 'historian search'
  • Want to filter the filter? No need to shell to grep, rather:
historian search while 'tr -s'  # search for commands that had the words `while` and `tr -s` in them

This would be equivalent to:

history |grep while |grep 'tr -s'

Why write another bash history?

My motivation is purely to learn go, and to have something useful out of it. If you end up using it too please drop me a line, I'd love to hear your experience or if there's any improvements in useability or code I can make. I'll be making updates as I go.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages