[Linux-disciples] Including the results of a program in a prompt

Adam Rosi-Kessel adam at rosi-kessel.org
Mon Nov 22 10:29:34 EST 2004


Stephen R Laniel wrote:
> I use this as my bash prompt, starting yesterday:
> PS1="(`date +'%H:%M:%S'`) \u@\h:\w\$ "
> This uses the string 'hours:minutes:seconds' as part of the
> prompt. Only it's not refreshing the time whenever a new
> prompt is displayed on the screen. Any idea why that would
> be? Does the backtick only go through when .bashrc is
> sourced? And if so, is there any way to get it to do what I
> want?

This is a variation on the last topic.

You need to escape the backticks, if you want them to be evaluated every 
time the prompt is displayed, i.e.:

PS1="(\`date +'%H:%M:%S'\`) \u@\h:\w\$ "

personally, I would just do:

PS1="(\T) \u@\h:\w\$ "

probably slightly more efficient.
-- 
Adam Rosi-Kessel
http://adam.rosi-kessel.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20041122/00487e09/signature.pgp


More information about the Linux-disciples mailing list