How to have the time displayed in bash prompt on SUSE

Having the time displayed in the bash prompt is useful because you always have a sort of log of duration/time of commands you give. For example, you need to copy a very large directory through the network: you press [Enter], you write your “cp” command that takes, say, one hour. After that, when you look at the screen, you can calculate how long it was running, minus a few seconds it took you to write the “cp” command. Of course you can accomplish the same using the “time” command like this: “time cp something somewhere”. But if you work a lot at the bash prompt (you’re a sysadmin) it’s very convenient in many situations, not only for the above example.

How to do it:

1. become root “su -”
2. edit /etc/bash.bashrc.local
3. add this line

export PS1="\t $PS1"

What this does: it puts the time (\t) in front of your existing prompt. This is the right way to do it too, because even if you upgrade the bash RPM, the bash.bashrc.local file remains untouched.

The prompt will look like this:

10:42:08 user@host:~>
Advertisements

One thought on “How to have the time displayed in bash prompt on SUSE

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s