summaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorDominik Ritter <dominik.ritter@pixelhouse.de>2015-03-29 19:06:57 +0300
committerDominik Ritter <dominik.ritter@pixelhouse.de>2015-03-29 19:06:57 +0300
commitdbcf3f74794282d6e652830af6cefd5110f70b9d (patch)
tree282bf3186850808f3a49d0f4635bd8c362b6afc8 /powerlevel9k.zsh-theme
parentba2ab6ec4a71b4df3dad39e81259490eea0bfa0a (diff)
A better approach to detect the dirty status of our working copy.
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rw-r--r--powerlevel9k.zsh-theme22
1 files changed, 13 insertions, 9 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 7edc05ea..ebc77fc9 100644
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -32,6 +32,7 @@ VCS_STAGED_ICON='✚'
# vcs_info settings for git
################################################################
+local VCS_WORKDIR_DIRTY=false
setopt prompt_subst
autoload -Uz vcs_info
zstyle ':vcs_info:*' stagedstr " %F{black}$VCS_STAGED_ICON%f"
@@ -101,17 +102,10 @@ prompt_context() {
# Git: branch/detached head, dirty status
prompt_vcs() {
- local dirty=false
local vcs_prompt="${vcs_info_msg_0_}"
if [[ -n $vcs_prompt ]]; then
- if [[ $vcs_prompt =~ $VCS_UNSTAGED_ICON ]]; then
- dirty=true
- elif [[ $vcs_prompt =~ $VCS_STAGED_ICON ]]; then
- dirty=true
- fi
-
- if ( $dirty ); then
+ if ( $VCS_WORKDIR_DIRTY ); then
$1_prompt_segment yellow black
else
$1_prompt_segment green black
@@ -170,6 +164,12 @@ function +vi-git-tagname() {
[[ -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
prompt_dir() {
$1_prompt_segment blue black '%~'
@@ -264,7 +264,11 @@ build_right_prompt() {
}
# 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) '
RPROMPT='%{%f%b%k%}$(build_right_prompt)%{$reset_color%}'