70c4a27fd6048c3213dd2f3bae21bff26005bc16
- Author
- leif.hanack <strug@web.de>
- Committer
- ncanceill <nicolas.canceill@ens-cachan.org>
- Date
Message
Added a possibility to display the remote branch and the number of commits you are ahead or behind
Diff
1diff --git a/lib/git.zsh b/lib/git.zsh
2index 118841f06efc88a698463a47698371c64619b5c5..733492ba0a62093745699ee24a92df90bf53982d 100644
3--- a/lib/git.zsh
4+++ b/lib/git.zsh
5@@ -36,16 +36,26 @@ git_remote_status() {
6 ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
7 behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
8
9- if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
10+ if [ $ahead -gt 0 ] && [ $behind -eq 0 ]
11 then
12- echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
13- elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
14+ git_remote_status="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
15+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}"
16+ elif [ $behind -gt 0 ] && [ $ahead -eq 0 ]
17 then
18- echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
19+ git_remote_status="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
20+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
21 elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
22 then
23- echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
24+ git_remote_status="$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
25+ git_remote_status_detailed="$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE$((ahead))%{$reset_color%}$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE$((behind))%{$reset_color%}"
26 fi
27+
28+ if [ $ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED ]
29+ then
30+ git_remote_status="$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX"
31+ fi
32+
33+ echo $git_remote_status
34 fi
35 }
36
37diff --git a/themes/strug.zsh-theme b/themes/strug.zsh-theme
38new file mode 100644
39index 0000000000000000000000000000000000000000..89b56b008672b996a25f69eff25337eb5fc1693a
40--- /dev/null
41+++ b/themes/strug.zsh-theme
42@@ -0,0 +1,25 @@
43+# terminal coloring
44+export CLICOLOR=1
45+export LSCOLORS=dxFxCxDxBxegedabagacad
46+
47+local git_branch='$(git_prompt_info)%{$reset_color%}$(git_remote_status)'
48+
49+PROMPT="%{$fg[green]%}╭─%n@%m %{$reset_color%}%{$fg[yellow]%}in %~ %{$reset_color%}${git_branch}
50+%{$fg[green]%}╰\$ %{$reset_color%}"
51+
52+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}on "
53+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
54+
55+ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}%{$fg[red]%} ✘ %{$reset_color%}"
56+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔ %{$reset_color%}"
57+
58+ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED=true
59+ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX="%{$fg[yellow]%}("
60+ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX="%{$fg[yellow]%})%{$reset_color%}"
61+
62+ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=" +"
63+ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR=%{$fg[green]%}
64+
65+ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE=" -"
66+ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR=%{$fg[red]%}
67+