Adding timestamp to each line on Zsh

I’ve found it more non-destructive to actually prepend the time to the existing prompt without overriding it completely. This makes it work with any existing theme without interfering with its styling.

Add this at the end of your .zshrc file. You can type the command nano ~/.zshrc to edit it using nano:

PROMPT='%{$fg[yellow]%}[%D{%f/%m/%y} %D{%L:%M:%S}] '$PROMPT

I use cloud theme, so this gives me:

enter image description here

It retains the current theme. You can also add some styling to the timestamp, by changing the color, or even the format.

Make sure to reload your .zshrc file by typing:

. ~/.zshrc

or

source ~/.zshrc

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)