Command-line history logging utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

  1. commandlog
  2. ==========
  3. A small set of tools for logging and annotating command-line history in a
  4. Linux or Unixlike environment. Requires Perl, sqlite, and zsh. (It
  5. probably won't take much to add to Bash, but I haven't tried yet.)
  6. So far, this is about an hour's worth of messing around one evening. It
  7. doesn't do much. Here's what I know works:
  8. ```sh
  9. # assuming Debian/Ubuntu and sqlite not already installed:
  10. sudo apt-get install sqlite3
  11. git clone git@github.com:brennen/commandlog
  12. cd commandlog
  13. perl Build.PL
  14. sudo ./Build installdeps
  15. sudo ./Build install
  16. ```
  17. Next, put the following in your `.zshrc`:
  18. ```zsh
  19. function preexec {
  20. commandlog add "$@"
  21. }
  22. ```
  23. Or, if using Oh-My-Zsh:
  24. ```zsh
  25. autoload -U add-zsh-hook
  26. function commandlog_preexec {
  27. commandlog add "$@"
  28. }
  29. add-zsh-hook preexec commandlog_preexec
  30. ```
  31. Now, with any luck, you can use:
  32. ```sh
  33. commandlog log
  34. ```
  35. And you should get output something like the following:
  36. 2018-03-23 05:29:22 v lib/App/CommandLog.pm
  37. 2018-03-23 05:29:09 vim Build.PL
  38. 2018-03-23 05:29:04 ll
  39. 2018-03-23 05:28:54 fg
  40. 2018-03-23 05:28:52 c log
  41. 2018-03-23 05:28:43 sudo ./Build install
  42. 2018-03-23 05:28:40 ./Build install
  43. 2018-03-23 05:28:37 cd ..
  44. 2018-03-23 05:28:34 ll
  45. 2018-03-23 05:28:32 mv commandlog-log.pl commandlog-log
  46. No promises though. If anybody tries this and has thoughts, please do let me
  47. know.