Last active
September 20, 2025 08:34
-
-
Save khursani8/5a025e9851b99f3ce8f331a147bbdc13 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # >>> MY_CUSTOM_ZSH >>> | |
| # Enable dynamic prompt substitution | |
| setopt PROMPT_SUBST | |
| # Track elapsed time | |
| preexec() { | |
| timer=$(date +%s%3N) | |
| } | |
| precmd() { | |
| if [ -n "$timer" ]; then | |
| now=$(date +%s%3N) | |
| elapsed=$(( (now - timer)/1000 )) # elapsed in seconds | |
| if [ $elapsed -ge 1 ]; then | |
| if [ $elapsed -ge 60 ]; then | |
| mins=$(( elapsed / 60 )) | |
| secs=$(( elapsed % 60 )) | |
| CMD_DURATION=" (${mins}m${secs}s)" | |
| else | |
| CMD_DURATION=" (${elapsed}s)" | |
| fi | |
| else | |
| CMD_DURATION="" | |
| fi | |
| fi | |
| } | |
| # Git branch helper | |
| git_branch() { | |
| ref=$(git symbolic-ref --short HEAD 2>/dev/null || git describe --tags --exact-match 2>/dev/null) | |
| [ -n "$ref" ] && echo "($ref)" | |
| } | |
| # Custom compact prompt with GMT+8 time | |
| PROMPT='%F{cyan}$(TZ=Asia/Singapore date "+%H:%M:%S")%f %F{yellow}%~%f %F{magenta}$(git_branch)%f%F{green}${CMD_DURATION}%f | |
| $ ' | |
| # <<< MY_CUSTOM_ZSH <<< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.