3 ms·
I use the following found zsh function to log each each command to file by date. I've definitely found value in looking up less frequently used or complex comm
by ndrake 7y ago
I use the following found zsh function to log each each command to file by date. I've definitely found value in looking up less frequently used or complex commands.
# Custom history logging
# From: http://blog.andrewhays.net/love-your-terminal http://blog.andrewhays.net/love-your-terminal
# https://web.archive.org/web/20130525150720/http://blog.andrewhays.net/love-your-terminal https://web.archive.org/web/20130525150720/http://blog.andre...
function precmd() {
if [ "$(id -u)" -ne 0 ]; then
FULL_CMD_LOG="$HOME/.shlogs/zsh-history-$(date -u "+%Y-%m-%d").log"
echo "$USER@`hostname`:`pwd` [$(date)] `\history -1`" >> ${FULL_CMD_LOG}
fi
}
- jlgaddis 7y agoHN pro-tip: When pasting code in comments, indent each line with two spaces for pre-formatted/fixed-width/monospaced (whatever you wanna call it) text (e.g., for code).