rename two internal variables for readability
* `prompt_pure_git_delay_dirty_check` holds the (finish) timestamp of the last dirty check (if the dirty check took more than 2 seconds); renamed to `prompt_pure_git_last_dirty_check_timestamp`. * Local variable `dirty_check` holds the elapsed time in seconds since the last dirty check (if the timestamp is set); renamed to `time_since_last_dirty_check`.
This commit is contained in:
17
pure.zsh
17
pure.zsh
@@ -83,7 +83,7 @@ prompt_pure_preprompt_render() {
|
|||||||
|
|
||||||
# set color for git branch/dirty status, change color if dirty checking has been delayed
|
# set color for git branch/dirty status, change color if dirty checking has been delayed
|
||||||
local git_color=242
|
local git_color=242
|
||||||
[[ -n ${prompt_pure_git_delay_dirty_check+x} ]] && git_color=red
|
[[ -n ${prompt_pure_git_last_dirty_check_timestamp+x} ]] && git_color=red
|
||||||
|
|
||||||
# construct prompt, beginning with path
|
# construct prompt, beginning with path
|
||||||
local prompt="%F{blue}%~%f"
|
local prompt="%F{blue}%~%f"
|
||||||
@@ -192,7 +192,7 @@ prompt_pure_async_tasks() {
|
|||||||
|
|
||||||
# reset git preprompt variables, switching working tree
|
# reset git preprompt variables, switching working tree
|
||||||
unset prompt_pure_git_dirty
|
unset prompt_pure_git_dirty
|
||||||
unset prompt_pure_git_delay_dirty_check
|
unset prompt_pure_git_last_dirty_check_timestamp
|
||||||
|
|
||||||
# set the new working tree, prefixed with "x"
|
# set the new working tree, prefixed with "x"
|
||||||
prompt_pure_current_working_tree="x${working_tree}"
|
prompt_pure_current_working_tree="x${working_tree}"
|
||||||
@@ -209,9 +209,9 @@ prompt_pure_async_tasks() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if dirty checking is sufficiently fast, tell worker to check it again, or wait for timeout
|
# if dirty checking is sufficiently fast, tell worker to check it again, or wait for timeout
|
||||||
local dirty_check=$(( $EPOCHSECONDS - ${prompt_pure_git_delay_dirty_check:-0} ))
|
local time_since_last_dirty_check=$(( $EPOCHSECONDS - ${prompt_pure_git_last_dirty_check_timestamp:-0} ))
|
||||||
if (( $dirty_check > ${PURE_GIT_DELAY_DIRTY_CHECK:-1800} )); then
|
if (( $time_since_last_dirty_check > ${PURE_GIT_DELAY_DIRTY_CHECK:-1800} )); then
|
||||||
unset prompt_pure_git_delay_dirty_check
|
unset prompt_pure_git_last_dirty_check_timestamp
|
||||||
# check check if there is anything to pull
|
# check check if there is anything to pull
|
||||||
async_job "prompt_pure" prompt_pure_async_git_dirty "${PURE_GIT_UNTRACKED_DIRTY:-1}" "$working_tree"
|
async_job "prompt_pure" prompt_pure_async_git_dirty "${PURE_GIT_UNTRACKED_DIRTY:-1}" "$working_tree"
|
||||||
fi
|
fi
|
||||||
@@ -227,9 +227,10 @@ prompt_pure_async_callback() {
|
|||||||
prompt_pure_git_dirty=$output
|
prompt_pure_git_dirty=$output
|
||||||
prompt_pure_preprompt_render
|
prompt_pure_preprompt_render
|
||||||
|
|
||||||
# when prompt_pure_git_delay_dirty_check is set, the git info is displayed in a different color, this is why the
|
# When prompt_pure_git_last_dirty_check_timestamp is set, the git info is displayed in a different color.
|
||||||
# prompt is rendered before the variable is (potentially) set
|
# To distinguish between a "fresh" and a "cached" result, the preprompt is rendered before setting this
|
||||||
(( $exec_time > 2 )) && prompt_pure_git_delay_dirty_check=$EPOCHSECONDS
|
# variable. Thus, only upon next rendering of the preprompt will the result appear in a different color.
|
||||||
|
(( $exec_time > 2 )) && prompt_pure_git_last_dirty_check_timestamp=$EPOCHSECONDS
|
||||||
;;
|
;;
|
||||||
prompt_pure_async_git_fetch)
|
prompt_pure_async_git_fetch)
|
||||||
prompt_pure_git_arrows=$(prompt_pure_check_git_arrows)
|
prompt_pure_git_arrows=$(prompt_pure_check_git_arrows)
|
||||||
|
|||||||
Reference in New Issue
Block a user