formatting the time in tcsh prompt

Greg Larkin glarkin at FreeBSD.org
Tue Jul 29 19:00:46 UTC 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chad Perrin wrote:
| 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'`] %~%# "
|
...
| There must be some way to do this.  Right?
|

Hi Chad,

Right!  Try this:

set prompt=' % '
alias precmd 'printf "[%s]" "`date +'%H%M'`"'

Best regards,
Greg
- --
Greg Larkin
http://www.sourcehosting.net/
http://www.FreeBSD.org/ - The Power To Serve
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIj2ji0sRouByUApARAopEAJ4vVmUZEZ7N+EKPn8fcMAcQGCXlJwCcCrqo
pk+1mKZ8Hn63DhZ3qlCWucQ=
=hqQT
-----END PGP SIGNATURE-----



More information about the freebsd-questions mailing list