News for hackers. Stuff that matters.
Re:When did I run that command? Update your Bash prompt with... by mikelward on Saturday April 18, 2020 @11:18PM (#22913227)
Isn't that printing the time the prompt was printed (the time the previous command finished)?

This is printing the time you pressed Enter (the time the command started), which is harder and less common, since that's not when the prompt is printed.

Re:When did I run that command? Update your Bash prompt with... by mikelward on Saturday April 18, 2020 @11:34PM (#22913291)
This is one way you could do something similar in zsh: https://stackoverflow.com/a/17915260/102182
Re:When did I run that command? Update your Bash prompt with... by countermeasure on Saturday April 18, 2020 @11:47PM (#22913348)
It looks like zsh can handle updating the time in the prompt quite simply and elegantly.
Re:When did I run that command? Update your Bash prompt with... by mikelward on Sunday April 19, 2020 @12:04AM (#22913428)
Yes, I find that solution much simpler.
Re:When did I run that command? Update your Bash prompt with... by Symbiote on Sunday April 19, 2020 @08:21AM (#22915394)
It keeps the clock up-to-date, but I use Konsole's "monitor for activity" feature, which changes the colour of inactive tabs if there is output.

Instead, this seems to work:

  TRAPDEBUG() {
    case "$WIDGET" in
      zle-line-finish)
        zle reset-prompt
        ;;
      *)
        ;;
    esac
  }
(I don't know if further cases will be required.)

This updates the prompt after "enter" is pressed, but before the command is executed.