[Linux-disciples] Including the results of a program in a prompt
Adam Rosi-Kessel
adam at rosi-kessel.org
Mon Nov 22 10:37:14 EST 2004
Actually, to clarify a bit.
Double quotes don't escape backticks.
Single quotes do.
There is a long history of this behavior. I may be mistaken, but I
think this is the primary difference between double and single quotes
for escaping in bash (aside from, of course, the fact that with double
quotes you don't need to escape internal single quotes and vice versa).
Thus, your other option is:
PS1='(\`date +'%H:%M:%S'\`) \u@\h:\w\$ '
Adam Rosi-Kessel wrote:
> 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.
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Linux-disciples mailing list
> Linux-disciples at lists.bostoncoop.net
> http://lists.bostoncoop.net/mailman/listinfo/linux-disciples
--
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/8d730e3b/signature-0001.pgp
More information about the Linux-disciples
mailing list