# # ~/projects/bash/histdb/NOTES --- # # $Id: NOTES,v 1.4 2007/10/22 18:50:27 harley Exp $ # "bash-histdb" logs your command history to a sqlite database as the commands are executed along with the current time and PWD of the command. Along with the logging of the commands, bash-histdb allows one to search these logged commands by command name, session or path. (Or some other sql expression you could think up.) INSTALLATION: -------------------- Unpack the archive and put bash-histdb in your path. The special features of the shell will only be activated when: * HISTDB_FILE is set before the shell starts, OR * "histdb_open -f filename" is run commands are then logged to the database. If you want to live large: | sudo mv /bin/bash /bin/bash.orig | sudo cp bash-histdb /bin/bash If you want to play safe, put bash somewhere else, like /usr/local/bin and set your Terminal.app preferences to invoke it rather than /bin/bash. Putting this into your startup file should start logging in bash-histdb, yet not break a normal bash shell: | if [ $(type -t histdb) = "builtin" ] | then | histdb_open -f ~/.bash_hist.db | fi Sqlite needs to be built with "./configure --disable-threadsafe" as I dont want pthreads to be required in bash. UPGRADE: -------------------- When upgrading from an old DB you will need to add a column: sqlite3 $HISTDB_FILE 'alter table bash_history add column ( host_name text );' USAGE: -------------------- Search your history with "histdb". The output is displayed form older to most recent, grouped into runs of commands in the same session. For example: | >>> 520965349 | 2007-10-19 00:04:19 | /disk/iris2/harley/projects/bash/histdb | 2 | ls | 1 | cd projects/bash/histdb/ | 3 | cvs up -d . | >>> 467789157 | 2007-10-19 00:09:51 | /disk/iris2/harley/projects/bash/histdb | 21 | make _distrib | 22 | ls | 23 | man bash | 24 | ./bash-histdb/bash Lines with ">>>" mark changes between sessions. The elements after ">>>" are sessionid, group start, PWD. This is followed by the command number and command. enjoy!, harley