I have a zsh
prompt I rather like: it evaluates the current time in precmd
and displays that on the right side of the prompt:
[Floatie:~] ^_^
cbowns% [9:28:31 on 2012-10-29]
However, this isn't exactly what I want: as you can see below, this time is actually the time the previous command exited, not the time the command was started:
[Floatie:~] ^_^
cbowns% date [9:28:26 on 2012-10-29]
Mon Oct 29 09:28:31 PDT 2012
[Floatie:~] ^_^
cbowns% date [9:28:31 on 2012-10-29]
Mon Oct 29 09:28:37 PDT 2012
[Floatie:~] ^_^
cbowns% [9:28:37 on 2012-10-29]
Is there a hook in zsh
to run a command just before the shell starts a new command so I can update the prompt timestamp then? (I saw Constantly updated clock in zsh prompt?, but I don't need it constantly updated, just updated when I hit enter.)
(The ^_^
is based on the previous command's return code. It shows ;_;
in red when there's a nonzero exit status.)
question from:
https://stackoverflow.com/questions/13125825/zsh-update-prompt-with-current-time-when-a-command-is-started 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…