Skip to content

Commit bade7c8

Browse files
committed
Add unpushed status.
1 parent bc2df38 commit bade7c8

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

config/zsh-custom/themes/custom.zsh-theme

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,38 @@ my_host() {
1010
}
1111

1212
# Unused –
13-
function my_git_prompt_info() {
14-
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
15-
GIT_STATUS=$(git_prompt_status)
16-
[[ -n $GIT_STATUS ]] && GIT_STATUS=" $GIT_STATUS"
17-
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/} $ZSH_THEME_GIT_PROMPT_SUFFIX"
13+
function get_git_branch {
14+
echo $(git rev-parse --abbrev-ref HEAD 2> /dev/null);
15+
}
16+
17+
function get_git_remote {
18+
echo $(git config --get branch.$branch.remote)
19+
}
20+
21+
function parse_git_unpushed {
22+
local branch=`get_git_branch`
23+
local remote=`get_git_remote`
24+
if [[ "$remote" == "" ]]; then
25+
# No remote
26+
echo -e ""
27+
else
28+
local pushed=$(git branch -v | grep "^* $branch")
29+
if [[ $pushed =~ "\[ahead [0-9]*" ]]
30+
then
31+
# Unpushed
32+
echo -e "🌱"
33+
else
34+
# Pushed
35+
echo -e "🌼"
36+
fi
37+
fi
1838
}
1939

2040
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}  "
21-
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
41+
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
2242

2343
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[red]%}✗"
24-
ZSH_THEME_GIT_PROMPT_CLEAN="%{$reset_color%} 🌼"
44+
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$reset_color%}"
2545

2646
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[red]%}✚%{$reset_color%}"
2747
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[red]%}✹%{$reset_color%}"
@@ -30,6 +50,6 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[red]%}➜%{$reset_color%}"
3050
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}═%{$reset_color%}"
3151
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}✭%{$reset_color%}"
3252

33-
PROMPT='%{$fg[white]%}%n$(my_host)%{$reset_color%} %{$fg_bold[blue]%}%4~%{$reset_color%} $(git_prompt_info)$(git_prompt_status)%{$reset_color%}
53+
PROMPT='%{$fg[white]%}%n$(my_host)%{$reset_color%} %{$fg_bold[blue]%}%4~%{$reset_color%} $(git_prompt_info)$(git_prompt_status)$(parse_git_unpushed)%{$reset_color%}
3454
$ '
3555
RPS1="${return_code}"

0 commit comments

Comments
 (0)