Show Time and Date in the Terminal

Show time and date in the terminal. You can show the time and date on the right side of the terminal. You should have a ZSH shell and oh-my-zsh to use this.

Show time and date in the terminal. You can show the time and date on the right side of the terminal. You should have a ZSH shell and oh-my-zsh to use this.

Add this into ~/.zshrc above source ~/.zshrc line for ZSH shell to show time & date on the right side of the terminal.

RPROMPT='${ret_status}%{$fg[green]%}~ %{$fg_bold[black]%}$(git_prompt_info)%{$bg[yellow]%}%{$fg[black]%} %D{%a, %f %b %Y} %{$bg[red]%}%{$fg[white]%}%D{ %L:%M:%S %p} % %{$reset_color%}'

Image preview:

only-time-and-date

Full image:

full

[Note: I am using Kali Linux with oh-my-zsh (agnoster theme) on ZSH shell in Windows Terminal WSL.]

You can change all the colors shown in the picture. change them in bg and fg. bg = background, fg = foreground .

See more about supported color

You can edit time and date format by changing them after %D .
Some Time format:

 %D     The date in yy-mm-dd format.
 %T     Current time of day, in 24-hour format.
 %t %@  Current time of day, in 12-hour, am/pm format.
 %*     Current time of day in 24-hour format, with seconds.
 %w     The date in day-dd format.
 %W     The date in mm/dd/yy format.
 %D{strftime-format}

See More about Time format

If you want this on left side, then just write PROMPT instead of RPROMPT .