formatting the time in tcsh prompt
Chad Perrin
perrin at apotheon.com
Tue Jul 29 18:25:09 UTC 2008
This might be slightly off-topic, I suppose -- but since (t)csh is the
default shell for FreeBSD, I figured this might be a good place to ask.
I'm aware of the %T option for showing 24-hour time in my tcsh prompt,
but it doesn't do exactly what I would like. Inserting a call to the
date command so I can have the exact formatting I want appears to fail by
only calculating the time once, and showing the same time every time the
prompt appears -- which means that, several hours later, I'm still
looking at the time from when the shell instance was started.
The prompt setting using the date command that I used is as follows:
set prompt = "[`date +'%H%M'`] %~%# "
At nine in the morning, that gives me:
[0900] ~>
. . . whereas the tcsh native time formatting for 24-hour time is:
set prompt = "[%T] %~%# "
At nine in the morning, that gives me:
[9:00] ~>
I would prefer to not have the colon in there, but it's not a big deal.
The biggest annoyance is the fact that the length of the time string
changes depending on whether it's an AM time or a PM time.
This is the best I've been able to get so far for a timestamp in the
prompt that updates every time the prompt is displayed:
[9:00] ~>
This is acceptable:
[09:00] ~>
This is most preferred:
[0900] ~>
There must be some way to do this. Right?
--
Chad Perrin [ content licensed PDL: http://pdl.apotheon.org ]
Jon Postel, RFC 761: "[B]e conservative in what you do, be liberal in
what you accept from others."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080729/5c12ebf9/attachment.pgp
More information about the freebsd-questions
mailing list