Currently my bash prompt looks like this

$ echo $PS1
# \[\e[34m\][\t]\[\e[0m\] \[\e]0;\w\a\]\[\e[34m\]\u@\h: \[\e[34m\]\w\[\e[0m\]\n$

The problem is that \t will only display the time when the prompt was rendered (which would be very close to the time of completion of the last command).

For me, it would be more useful to display the time at which the current command process was started. Is there a way to do this?

  • I wonder what difference it will make to your prompt? A few milliseconds cannot cause problems, can they?
    – phunehehe
    Oct 24, 2010 at 8:20
  • 1
    There are some commands which will take a little bit longer ;-)
    – echox
    Oct 24, 2010 at 9:45

2 Answers 2


If I understand you correctly, you want to change the prompt when you start the current command. I don't think bash has a prompt-changing feature, but you can perhaps redraw over the prompt, if you can locate it (not so easy for multi-line commands).

In zsh, you would use the precmd function. Bash doesn't have a similar feature, but it can be hacked up.


No, because there could be any length of time between the prompt and you entering your command, and then pressing the ENTER key.

You could set up an alias for a non command (say doit) that displayed the time and then execute the command it was passed. It would require you remembering to use it every time, and it would only work on systems (and accounts) that you'd configured it on.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .