Skip to content

Instantly share code, notes, and snippets.

@kundancool
Forked from zulhfreelancer/zsh-timestamp.md
Created February 18, 2022 12:54
Show Gist options
  • Save kundancool/9074dd27c811eafdbd71d5b0961ef2cb to your computer and use it in GitHub Desktop.
Save kundancool/9074dd27c811eafdbd71d5b0961ef2cb 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

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