Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11913
| From | isabella parakiss <izaberina@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Proposed Prompt Escapes |
| Date | 2015-11-19 05:49 +0100 |
| Message-ID | <mailman.204.1447908589.31583.bug-bash@gnu.org> (permalink) |
| References | <CANaoh6KA9Z3Uo_8qy-biaQx6MW1Z3h7DsC2uU-M=RTwrPPGBVA@mail.gmail.com> <1447798606.2074.5.camel@16bits.net> <CANaoh6LB3h9RciQgU0jh+GuJks0Px1=Bk+QJpd70xk9+8EbbWQ@mail.gmail.com> <1447899698.5874.4.camel@16bits.net> |
On 11/19/15, Ángel González <angel@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
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Proposed Prompt Escapes isabella parakiss <izaberina@gmail.com> - 2015-11-19 05:49 +0100
csiph-web