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 ...
- I'd like to get rid of
go get github.com/svanellewee/historianAdd 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"To see the last 10 commands used inside the current directory, run
historian last 10To see all the commands you ran and at what times and where for today just ask:
historian todayThis 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)
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
bindand/orshutdown
historian search 'bind|shutdown'- You wrote this dumb history app called
historianand 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 themThis would be equivalent to:
history |grep while |grep 'tr -s'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.