On 11/19/15, Ángel González <an...@16bits.net> wrote: > Dennis Williamson wrote: >> Do you mean something like: >> >> PS1='$SECONDS ' > > Not exactly. $SECONDS is the number of seconds since the shell was > started. I am interested in the seconds elapsed by the last command. > > It is a hacky solution, but it could be done with: >> PS1=''; PROMPT_COMMAND='printf "%s " $SECONDS; SECONDS=0' > >
You need to reset it right before the command is executed, PROMPT_COMMAND is evaluated when the prompt is drawn, before you type your command. A debug trap is better suited, but you have to make sure that it's only executed once in a complex line. Something along these lines should work: PROMPT_COMMAND=debug_trap=0 trap '((!debug_trap++))&&SECONDS=0' debug PS1='$SECONDS \$ ' --- xoxo iza