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.

Revisions

  1. tomnomnom created this gist Dec 18, 2024.
    9 changes: 9 additions & 0 deletions bash-timestamp.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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