Are 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
nevermind, managed to get this working for fish, just add it to the end of your ~/.config/fish/config.fish file :)
And, since I keep editing this comment... blog post about it with all credit to OP and OP's inspirationhttps://bryan-lott.github.io/log-all-commands/