Session recording
VirginSnow at vfemail.net
VirginSnow at vfemail.net
Mon Mar 31 19:44:52 EDT 2008
> Date: Mon, 31 Mar 2008 17:59:11 -0400 (EDT)
> From: "John Abreau" <jabr at blu.org>
> Cc: gnhlug-discuss at mail.gnhlug.org
> >> ...
> >> export PS1='[ `date` ]'
> >> ...
> >>
> >
> > Note: That will probably not do what you intended... Each time a
> > prompt is issued, the same exact prompt will be issued, namely
> > "[ Mon Mar 31 17:32:54 UTC 2008]". "date" will not be rerun
> > before each prompt. To do that, you need to use $PROMPT_COMMAND.
>
>
> Did you try it first before declaring that it won't work?
> I just gave it a try, and it does indeed run the date
> command for each prompt.
>
> [ Mon Mar 31 17:54:54 EDT 2008 ]
> [ Mon Mar 31 17:54:57 EDT 2008 ]
> [ Mon Mar 31 17:55:04 EDT 2008 ]
I said it would "probably" not do what was intended. I was "probably"
wrong, as well. :)
As it turns out, it REALLY depends on the value of the "promptvars"
shell option.
user at localhost$ shopt -s promptvars
user at localhost$ PS1='[ `date` ] $ '
[ Mon Mar 31 19:34:51 EDT 2008 ] $
[ Mon Mar 31 19:34:52 EDT 2008 ] $
[ Mon Mar 31 19:34:53 EDT 2008 ] $
[ Mon Mar 31 19:34:54 EDT 2008 ] $ shopt -u promptvars
[ `date` ] $
[ `date` ] $
[ `date` ] $
[ `date` ] $
I was thinking you'd have to use PS1='[ \D{%x %X} ] $ '. But it seems
that I was wrong. That happens on occasion. :) Using \D doesn't spawn
extra processes with each prompt, so my way is more efficient
anyway. :P (Watch, now somebody'll prove me wrong about that too..!)
More information about the gnhlug-discuss
mailing list