6ff53d173b374e5ebbdff141059c71e4e14aa62e
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh
2index ccba22dc51ba7d860deb9ccecf6a581410b7457b..5175bf70f91d0fafddebfd72a74eea5435131213 100644
3--- a/plugins/git-prompt/git-prompt.plugin.zsh
4+++ b/plugins/git-prompt/git-prompt.plugin.zsh
5@@ -1,24 +1,13 @@
6 # ZSH Git Prompt Plugin from:
7 # http://github.com/olivierverdier/zsh-git-prompt
8
9-export __GIT_PROMPT_DIR=${0:A:h}
10+__GIT_PROMPT_DIR="${0:A:h}"
11
12-export GIT_PROMPT_EXECUTABLE=${GIT_PROMPT_USE_PYTHON:-"python"}
13-
14-# Initialize colors.
15-autoload -U colors
16-colors
17-
18-# Allow for functions in the prompt.
19-setopt PROMPT_SUBST
20-
21-autoload -U add-zsh-hook
22-
23-add-zsh-hook chpwd chpwd_update_git_vars
24-add-zsh-hook preexec preexec_update_git_vars
25-add-zsh-hook precmd precmd_update_git_vars
26+## Hook function definitions
27+function chpwd_update_git_vars() {
28+ update_current_git_vars
29+}
30
31-## Function definitions
32 function preexec_update_git_vars() {
33 case "$2" in
34 git*|hub*|gh*|stg*)
35@@ -34,64 +23,59 @@ function precmd_update_git_vars() {
36 fi
37 }
38
39-function chpwd_update_git_vars() {
40- update_current_git_vars
41-}
42+chpwd_functions+=(chpwd_update_git_vars)
43+precmd_functions+=(precmd_update_git_vars)
44+preexec_functions+=(preexec_update_git_vars)
45
46+
47+## Function definitions
48 function update_current_git_vars() {
49 unset __CURRENT_GIT_STATUS
50
51- if [[ "$GIT_PROMPT_EXECUTABLE" == "python" ]]; then
52- local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
53- _GIT_STATUS=`python ${gitstatus} 2>/dev/null`
54- fi
55- if [[ "$GIT_PROMPT_EXECUTABLE" == "haskell" ]]; then
56- local gitstatus="$__GIT_PROMPT_DIR/dist/build/gitstatus/gitstatus"
57- _GIT_STATUS=`${gitstatus}`
58- fi
59+ local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
60+ _GIT_STATUS=$(python ${gitstatus} 2>/dev/null)
61 __CURRENT_GIT_STATUS=("${(@s: :)_GIT_STATUS}")
62- GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
63- GIT_AHEAD=$__CURRENT_GIT_STATUS[2]
64- GIT_BEHIND=$__CURRENT_GIT_STATUS[3]
65- GIT_STAGED=$__CURRENT_GIT_STATUS[4]
66- GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5]
67- GIT_CHANGED=$__CURRENT_GIT_STATUS[6]
68- GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
69+ GIT_BRANCH=$__CURRENT_GIT_STATUS[1]
70+ GIT_AHEAD=$__CURRENT_GIT_STATUS[2]
71+ GIT_BEHIND=$__CURRENT_GIT_STATUS[3]
72+ GIT_STAGED=$__CURRENT_GIT_STATUS[4]
73+ GIT_CONFLICTS=$__CURRENT_GIT_STATUS[5]
74+ GIT_CHANGED=$__CURRENT_GIT_STATUS[6]
75+ GIT_UNTRACKED=$__CURRENT_GIT_STATUS[7]
76 }
77
78-
79 git_super_status() {
80- precmd_update_git_vars
81+ precmd_update_git_vars
82 if [ -n "$__CURRENT_GIT_STATUS" ]; then
83- STATUS="$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH%{${reset_color}%}"
84- if [ "$GIT_BEHIND" -ne "0" ]; then
85- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND%{${reset_color}%}"
86- fi
87- if [ "$GIT_AHEAD" -ne "0" ]; then
88- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD$GIT_AHEAD%{${reset_color}%}"
89- fi
90- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_SEPARATOR"
91- if [ "$GIT_STAGED" -ne "0" ]; then
92- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED$GIT_STAGED%{${reset_color}%}"
93- fi
94- if [ "$GIT_CONFLICTS" -ne "0" ]; then
95- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CONFLICTS$GIT_CONFLICTS%{${reset_color}%}"
96- fi
97- if [ "$GIT_CHANGED" -ne "0" ]; then
98- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CHANGED$GIT_CHANGED%{${reset_color}%}"
99- fi
100- if [ "$GIT_UNTRACKED" -ne "0" ]; then
101- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED%{${reset_color}%}"
102- fi
103- if [ "$GIT_CHANGED" -eq "0" ] && [ "$GIT_CONFLICTS" -eq "0" ] && [ "$GIT_STAGED" -eq "0" ] && [ "$GIT_UNTRACKED" -eq "0" ]; then
104- STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"