I would like tcsh to print the time that each command is executed, preferably in the right-hand column of the screen. This is similar to what rprompt can be used to do with the following setting,

set rprompt = "%P"

except that the above prints the time when the prompt was printed on the screen, not the time that the next command is executed. I find this unhelpful; If I haven't typed a command for some time, and then execute a command, the time printed next to the command does not reflect when I executed that command. I thought that the following would do it,

alias postcmd 'set rprompt="`date +%T`"'

by dynamically changing the value of rprompt before each command is executed, but this also doesn't do it; it does not update the time to the time when the command is executed. (And actually, I don't understand why.) Setting precmd doesn't do it either.

How can I accomplish this?

My question is essentially identical to this question, except that I use tcsh and not bash, and the other question's accepted answer (i.e., setting precmd) does not appear to work for me.

  • I take it "history" with timestamps does not suffice for your purposes? – user2267 Jan 6 '16 at 5:10
  • I do know about the history facility, but I'm hoping to find something automatic. Using the history command takes more time, disrupts your train of thought, etc. Plus, this is one of those things that makes me think "there's just got to be a way to do such a simple thing..." – mhucka Jan 6 '16 at 6:04
  • The value that you want is shown by rprompt, but on the following line. tcsh does not have a way to redraw the previously-drawn rprompt output. – Thomas Dickey Jan 6 '16 at 10:25
  • @ThomasDickey Ah, so you mean, the postcmd setting is actually working, but it's just that the text is not being redrawn as expected? – mhucka Jan 8 '16 at 6:35
  • yes - I didn't see any easy/portable way for you to modify this, else I would have expanded on that in an answer. – Thomas Dickey Jan 8 '16 at 9:01

Your Answer

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

Browse other questions tagged or ask your own question.