Last active
November 2, 2020 04:41
-
-
Save Roger-Wu/7635a01a03b4d338a45ff417fea4759b to your computer and use it in GitHub Desktop.
This file contains 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
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}⚡" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
function prompt_char { | |
if [ $UID -eq 0 ]; then echo "%{$fg[red]%}#%{$reset_color%}"; else echo $; fi | |
} | |
# PROMPT='%(?, ,%{$fg[red]%}FAIL: $?%{$reset_color%} | |
# ) | |
# %{$fg[magenta]%}%n%{$reset_color%}@%{$fg[yellow]%}%m%{$reset_color%}: %{$fg_bold[blue]%}%~%{$reset_color%}$(git_prompt_info) | |
# $(prompt_char) ' | |
function preexec() { | |
timer=$(date +%s%3N) | |
} | |
function precmd() { | |
if [ $timer ]; then | |
local now=$(date +%s%3N) | |
local d_ms=$(($now-$timer)) | |
local d_s=$((d_ms / 1000)) | |
local ms=$((d_ms % 1000)) | |
local s=$((d_s % 60)) | |
local m=$(((d_s / 60) % 60)) | |
local h=$((d_s / 3600)) | |
if ((h > 0)); then prompt_elapsed=${h}h${m}m | |
elif ((m > 0)); then prompt_elapsed=${m}m${s}s | |
elif ((s >= 10)); then prompt_elapsed=${s}.$((ms / 100))s | |
elif ((s > 0)); then prompt_elapsed=${s}.$((ms / 10))s | |
else prompt_elapsed=${ms}ms | |
fi | |
# export RPROMPT="%F{cyan}${prompt_elapsed} %{$reset_color%}" | |
unset timer | |
fi | |
prompt_date_time=`date +"%Y-%m-%d %H:%M:%S"` | |
} | |
PROMPT='' | |
PROMPT+='%(?,,%{$fg[red]%}FAIL: $?%{$reset_color%} | |
)' | |
PROMPT+='%{$fg[yellow]%}%n%{$reset_color%}' | |
PROMPT+='@%{$fg[green]%}%M%{$reset_color%}' | |
PROMPT+=' %{$fg[cyan]%}%~%{$reset_color%}' | |
PROMPT+=' $(git_prompt_info)' | |
PROMPT+=' %{$fg[magenta]%}$prompt_elapsed%{$reset_color%}' | |
# PROMPT+=' %{$fg[white]%}%D %*%{$reset_color%}' | |
PROMPT+=' %{$fg[white]%}$prompt_date_time%{$reset_color%}' | |
PROMPT+=' | |
$(prompt_char) ' | |
RPROMPT='' | |
# $FG[033]: bright blue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment