Skip to content

Instantly share code, notes, and snippets.

@tomnomnom
Created December 18, 2024 11:22
Show Gist options
  • Save tomnomnom/a86f5d215cf8c83c26c5f7a58cc697ae to your computer and use it in GitHub Desktop.
Save tomnomnom/a86f5d215cf8c83c26c5f7a58cc697ae to your computer and use it in GitHub Desktop.
Print a grey timestamp before running bash commands
PROMPT_COMMAND='PS1_RUN_PREEXEC=1'
preexec() {
if [ -z "$PS1_RUN_PREEXEC" ]; then
return
fi
unset PS1_RUN_PREEXEC
echo $'\e[38;5;241m'"[$(date +'%Y-%m-%dT%H:%M:%S%z')]"$'\e[0m'
}
trap 'preexec' DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment