Command-line history logging utilities
Perl Shell Perl6
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
lib/App
t
.gitignore
Build.PL
README.md
benchmark.pl

README.md

commandlog

A small set of tools for logging and annotating command-line history in a Linux or Unixlike environment. Requires Perl, sqlite, and zsh. (It probably won't take much to add to Bash, but I haven't tried yet.)

So far, this is about an hour's worth of messing around one evening. It doesn't do much. Here's what I know works:

# assuming Debian/Ubuntu and sqlite not already installed:
sudo apt-get install sqlite3

git clone git@github.com:brennen/commandlog
cd commandlog
perl Build.PL
sudo ./Build installdeps
sudo ./Build install

Next, put the following in your .zshrc:

function preexec {
  commandlog add "$@"
}

Or, if using Oh-My-Zsh:

autoload -U add-zsh-hook
function commandlog_preexec {
  commandlog add "$@"
}
add-zsh-hook preexec commandlog_preexec

Now, with any luck, you can use:

commandlog log

And you should get output something like the following:

              id = 96
         command = commandlog log
expanded_command = commandlog log
            path = /home/brennen/code/commandlog
        hostname = exuberance
        username = brennen
           shell = /usr/bin/zsh
        terminal = xterm
           notes = 
        datetime = 2016-10-26 03:56:12

              id = 95
         command = vim README.md
expanded_command = vim README.md
            path = /home/brennen/code/commandlog
        hostname = exuberance
        username = brennen
           shell = /usr/bin/zsh
        terminal = xterm
           notes = 
        datetime = 2016-10-26 03:48:40

              id = 94
         command = ll
expanded_command = ls --color -l
            path = /home/brennen/code/commandlog
        hostname = exuberance
        username = brennen
           shell = /usr/bin/zsh
        terminal = xterm
           notes = 
        datetime = 2016-10-26 03:48:30

No promises though. If anybody tries this and has thoughts, please do let me know.