Skip to content

Instantly share code, notes, and snippets.

@thcipriani
Created February 28, 2024 00:40
Show Gist options
  • Save thcipriani/8d098f4fc54b5699845a512dd2805253 to your computer and use it in GitHub Desktop.
Save thcipriani/8d098f4fc54b5699845a512dd2805253 to your computer and use it in GitHub Desktop.
FIRST_PROMPT=1
muh_history() {
# First prompt of a new session, don't log
[ -n "$FIRST_PROMPT" ] && {
unset FIRST_PROMPT
return
}
local hist
hist=$(history 1 | { read -r _ cmd; echo "$cmd"; })
echo "$$ $PWD $USER $hist" >> "$HOME/.muh_history"
}
PROMPT_COMMAND=muh_history
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment