Skip to content

Instantly share code, notes, and snippets.

@MarkWalters-dev
Last active December 24, 2020 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkWalters-dev/24ac9176d74352c3dafc9efdc5ff7d17 to your computer and use it in GitHub Desktop.
Save MarkWalters-dev/24ac9176d74352c3dafc9efdc5ff7d17 to your computer and use it in GitHub Desktop.
Log history after every command in multiple sessions
export BASHLOG=$HOME/.local/share/bashlog
[ -e "$BASHLOG" ] || mkdir -p $BASHLOG
[ -n "$TERM_SESSION_ID" ] || export TERM_SESSION_ID="$(uuidgen)"
export PROMPT_COMMAND='echo "$(printf "%(%F.%H:%M:%S)T\n") $TERM_SESSION_ID $PWD $(history 1)" >> $BASHLOG/$(printf "%(%F)T\n").log'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment