3 ms·
Save your local shell history to log files
- mystickphoenix 4y agoAre there any shell-agnostic ways of doing this? I tend to bounce between zsh, fish, although fish has been sticking lately so a fish version of this would be amazing. nevermind, managed to get this working for fish, just add it to the end of your ~/.config/fish/config.fish file :) # log every command function cmd_log --on-event fish_preexec if test (id -u) -ne 0 # if we're already sudo, don't log echo $(date "+%Y-%m-%d.%H:%M:%S"): $(pwd): $argv >> ~/.logs/cmd-history-$(date "+%Y-%m-%d").log end end And, since I keep editing this comment... blog post about it with all credit to OP and OP's inspiration https://bryan-lott.github.io/log-all-commands/ https://bryan-lott.github.io/log-all-commands/