You can use \d in the your PS1 confuration to display a long date ie. Tues 18 May, but how can I get it to display it in a format like 18.05.2012 for example?
Here are the different meanings for the different parts of the BASH prompt: PS1 – This is the primary prompt display. This is where you set special characters or important information. PS2 – This is the secondary prompt string.
To display timestamp on command prompt, use the special character \D{} for PS1 shell variable. It is possible to display arbitrary time format by putting a special character based on strftime() function into {} . For more information on special characters, refer to the online manual “STRFTIME(3) man 3 strftime. ”
The PS1 variable contains the value of the default prompt. It is used to change the looks and environment of the shell command prompt. Different examples of using the PS1 variable have been shown in this tutorial.
In Linux, the PS1 system variable is used to change the prompt setting. To change the Linux prompt permanently, you need to modify the . bashrc file which initializes the interactive shell session whenever the system starts.
Try including \D{%d.%m.%Y}
. You can use any time format supported by strftime(3)
.
Try this:
PS1="\$(date +%d.%m.%Y) > " export PS1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With