mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2024-11-16 17:50:09 +00:00
A better approach to detect the dirty status of our working copy.
This commit is contained in:
parent
ba2ab6ec4a
commit
dbcf3f7479
1 changed files with 13 additions and 9 deletions
|
@ -32,6 +32,7 @@ VCS_STAGED_ICON='✚'
|
||||||
# vcs_info settings for git
|
# vcs_info settings for git
|
||||||
################################################################
|
################################################################
|
||||||
|
|
||||||
|
local VCS_WORKDIR_DIRTY=false
|
||||||
setopt prompt_subst
|
setopt prompt_subst
|
||||||
autoload -Uz vcs_info
|
autoload -Uz vcs_info
|
||||||
zstyle ':vcs_info:*' stagedstr " %F{black}$VCS_STAGED_ICON%f"
|
zstyle ':vcs_info:*' stagedstr " %F{black}$VCS_STAGED_ICON%f"
|
||||||
|
@ -101,17 +102,10 @@ prompt_context() {
|
||||||
|
|
||||||
# Git: branch/detached head, dirty status
|
# Git: branch/detached head, dirty status
|
||||||
prompt_vcs() {
|
prompt_vcs() {
|
||||||
local dirty=false
|
|
||||||
local vcs_prompt="${vcs_info_msg_0_}"
|
local vcs_prompt="${vcs_info_msg_0_}"
|
||||||
|
|
||||||
if [[ -n $vcs_prompt ]]; then
|
if [[ -n $vcs_prompt ]]; then
|
||||||
if [[ $vcs_prompt =~ $VCS_UNSTAGED_ICON ]]; then
|
if ( $VCS_WORKDIR_DIRTY ); then
|
||||||
dirty=true
|
|
||||||
elif [[ $vcs_prompt =~ $VCS_STAGED_ICON ]]; then
|
|
||||||
dirty=true
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ( $dirty ); then
|
|
||||||
$1_prompt_segment yellow black
|
$1_prompt_segment yellow black
|
||||||
else
|
else
|
||||||
$1_prompt_segment green black
|
$1_prompt_segment green black
|
||||||
|
@ -170,6 +164,12 @@ function +vi-git-tagname() {
|
||||||
[[ -n ${tag} ]] && hook_com[branch]=" %F{black}${tag}%f"
|
[[ -n ${tag} ]] && hook_com[branch]=" %F{black}${tag}%f"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function +vi-vcs-detect-changes() {
|
||||||
|
if [[ -n ${hook_com[staged]} ]] || [[ -n ${hook_com[unstaged]} ]]; then
|
||||||
|
VCS_WORKDIR_DIRTY=true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Dir: current working directory
|
# Dir: current working directory
|
||||||
prompt_dir() {
|
prompt_dir() {
|
||||||
$1_prompt_segment blue black '%~'
|
$1_prompt_segment blue black '%~'
|
||||||
|
@ -264,7 +264,11 @@ build_right_prompt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the prompts
|
# Create the prompts
|
||||||
precmd() { vcs_info }
|
precmd() {
|
||||||
|
vcs_info
|
||||||
|
# Add a static hook to examine staged/unstaged changes.
|
||||||
|
vcs_info_hookadd set-message vcs-detect-changes
|
||||||
|
}
|
||||||
|
|
||||||
PROMPT='%{%f%b%k%}$(build_left_prompt) '
|
PROMPT='%{%f%b%k%}$(build_left_prompt) '
|
||||||
RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}'
|
RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}'
|
||||||
|
|
Loading…
Reference in a new issue