Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active September 12, 2024 15:41
Show Gist options
  • Save zulhfreelancer/9c410cad5efa9c5f7c74cd0849765865 to your computer and use it in GitHub Desktop.
Save zulhfreelancer/9c410cad5efa9c5f7c74cd0849765865 to your computer and use it in GitHub Desktop.
How to add timestamp on right hand side of ZSH / iTerm2 terminal prompt?

Add the following snippet at the bottom of ~/.zshrc file.

Option 1 - Just time

RPROMPT='[%D{%L:%M:%S}] '$RPROMPT

Option 2 - Date and time

RPROMPT="[%D{%f/%m/%y} | %D{%L:%M:%S}]"

When you are done, run $ source ~/.zshrc to see the effect. If it doesn't work, quit iTerm2 and open it again.


Resources

@Nassim-sadi
Copy link

Thank you , i added it to Custom Theme (Pi) and it worked also .

@swhasans
Copy link

swhasans commented May 5, 2023

Thanks!

@kotwanikunal
Copy link

RPROMPT="[%D{%m/%f/%y} | %D{%L:%M:%S}]" for the US date format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment