Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add the current time to my bash in Redhat. I'd like it to read:

[user@hostname 01:01:01 ~] and obviously be relative to when the bash prompt was placed there.

Any ideas if this is possible, and if so, how?

share|improve this question
up vote 1 down vote accepted

Did you try the PROMPT_COMMAND found here?

PROMPT_COMMAND="echo -n \[\$(date +%H:%M:%S)\]"
PS1=" "$PS1"\[\e]30;\u@\h\a\]"

Bear in mind that it won't give the time stamp for the current command, but the one before.

share|improve this answer
That worked great! Thank you :) – Sugitime Aug 20 '13 at 20:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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