I learned from the question date - HH:MM:SS (with AM/PM) 12 Hour Timestamp for Bash Prompt - Unix & Linux Stack Exchange and fine-tune my prompt as:
export PS1='\D{%r}:\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]:\n$ '
08:52:31 PM:me@host:~:
$
The time format is not very comfortable, the result I desire is
08:52PM me@host~:
How could I get such a HH:MM(AM/PM) format\
The final result
export PS1='\D{%I:%M%p %d/%m %A}:\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]:\n$ '
10:45PM 18/03 Monday:me@host:~:
$ ls '$tty'
The supported formats are those documented in
man date
. So instead ofyou can use
So change
\D{%r}
to\D{%I:%M%p}
Use
\@
(the current time in 12-hour am/pm format) instead of\D{%r}
, that produces times inHH:MM (AM|PM)
format.