Re:Show HN: Private cloud shell history. Open source server ...
by ndrake on Monday February 10, 2020 @11:22AM
(#22290463)
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.
Re:Show HN: Private cloud shell history. Open source server ...
by jlgaddis on Monday February 10, 2020 @04:58PM
(#22293842)
HN 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).
# Custom history logging # From: 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 }