I am attempting to simply get a standard lexigraphical time display in the prompt and the history file in the range of 00:00:00 to 23:59:59. I've tried

set prompt=%P$ 

but this just produces, for example,


when time is before noon. I need it to display 07:12:43 instead so that the times sort correctly and the widths are uniform. Can I do this?


You can get this behavior with set padhour:

ubuntu:~> set prompt="%P>"
0:36:03>set padhour

Also tested on FreeBSD 10.

From the man page:

Special shell variables
    padhour If set, enable the printing of padding '0' for hours,
            in 24 and 12 hour formats.  E.G.: 07:45:42 vs. 7:45:42.
  • Thanks, but apparently my version of tcsh (6.14) doesn't implement this shell variable. I will need to update the shell to try it. – ThomasMcLeod Mar 7 '15 at 8:02
  • OK. If you have the source to your version, adding support for padhour is a 2-line change to the code. The diff on github is here: github.com/tcsh-org/tcsh/commit/… – Mark Plotnick Mar 10 '15 at 22:35
  • Thanks but I'm on a corporate server. I wouldn't even know who to ask to recompile. It's on tsch 6.14.00 (Astron) 2005-03-25. – ThomasMcLeod Mar 10 '15 at 23:38
  • How hard is it to just run a private shell version? – ThomasMcLeod Mar 10 '15 at 23:40
  • If you put the new shell in, say, ~thomas/bin/tcsh, you can put setenv SHELL ~thomas/bin/tcsh; $SHELL in your ~/.login to run it. – Mark Plotnick Mar 11 '15 at 1:20

You need to put this in the begining (or anywhere else you want) of your PS1 variable in your .tcshrc file:


For example:

PS1='(\D{%H:%M:%S}) <\u@\h\W>'

The time will be the time when you get the prompt back, it wont update as time goes by.

  • This is a tcsh question, not bash. – Martin Tournoij Mar 7 '15 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.