diff options
author | Alan Pearce | 2014-07-01 16:46:40 +0100 |
---|---|---|
committer | Alan Pearce | 2014-07-01 16:46:40 +0100 |
commit | 2829eaf03303d970e01560ffe05e21ea233cb2e1 (patch) | |
tree | 51e8e1358e5351b359a7312d11f69c9aa9dd0e17 /tag-zsh | |
parent | 42b9a19452cd8ed458d77fdaebad91d290cc4e65 (diff) | |
download | nixfiles-2829eaf03303d970e01560ffe05e21ea233cb2e1.tar.lz nixfiles-2829eaf03303d970e01560ffe05e21ea233cb2e1.tar.zst nixfiles-2829eaf03303d970e01560ffe05e21ea233cb2e1.zip |
zsh: Update pure prompt
Diffstat (limited to 'tag-zsh')
-rw-r--r-- | tag-zsh/config/zsh/functions/pure/prompt_pure_setup | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tag-zsh/config/zsh/functions/pure/prompt_pure_setup b/tag-zsh/config/zsh/functions/pure/prompt_pure_setup index 5c635037..5b92ee5c 100644 --- a/tag-zsh/config/zsh/functions/pure/prompt_pure_setup +++ b/tag-zsh/config/zsh/functions/pure/prompt_pure_setup @@ -43,14 +43,14 @@ prompt_pure_git_dirty() { # displays the exec time of the last command if set threshold was exceeded prompt_pure_cmd_exec_time() { - local stop=$(date +%s) + local stop=$EPOCHSECONDS local start=${cmd_timestamp:-$stop} integer elapsed=$stop-$start (($elapsed > ${PURE_CMD_MAX_EXEC_TIME:=5})) && prompt_pure_human_time $elapsed } prompt_pure_preexec() { - cmd_timestamp=$(date +%s) + cmd_timestamp=$EPOCHSECONDS # shows the current dir and executed command in the title when a process is active print -Pn "\e]0;" @@ -70,7 +70,7 @@ prompt_pure_precmd() { # git info vcs_info - local prompt_pure_preprompt='\n%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_pure_git_dirty` $prompt_pure_username%f %F{yellow}`prompt_pure_cmd_exec_time`%f' + local prompt_pure_preprompt="\n%F{blue}%~%F{242}$vcs_info_msg_0_`prompt_pure_git_dirty` $prompt_pure_username%f %F{yellow}`prompt_pure_cmd_exec_time`%f" print -P $prompt_pure_preprompt # check async if there is anything to pull @@ -80,10 +80,12 @@ prompt_pure_precmd() { # check check if there is anything to pull command git fetch &>/dev/null && # check if there is an upstream configured for this branch - command git rev-parse --abbrev-ref @'{u}' &>/dev/null && - (( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && - # some crazy ansi magic to inject the symbol into the previous line - print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}⇣%f\e8" + command git rev-parse --abbrev-ref @'{u}' &>/dev/null && { + local arrows='' + (( $(command git rev-list --right-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows='⇣' + (( $(command git rev-list --left-only --count HEAD...@'{u}' 2>/dev/null) > 0 )) && arrows+='⇡' + print -Pn "\e7\e[A\e[1G\e[`prompt_pure_string_length $prompt_pure_preprompt`C%F{cyan}${arrows}%f\e8" + } } &! # reset value since `preexec` isn't always triggered @@ -98,6 +100,7 @@ prompt_pure_setup() { prompt_opts=(cr subst percent) + zmodload zsh/datetime autoload -Uz add-zsh-hook autoload -Uz vcs_info |