@@ -8,6 +8,7 @@ IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-git-show-curre
88IFS=' ' read -r -a diff_symbol <<< $( get_tmux_option " @dracula-git-show-diff-symbol" " !" )
99IFS=' ' read -r -a no_repo_message <<< $( get_tmux_option " @dracula-git-no-repo-message" " " )
1010IFS=' ' read -r -a no_untracked_files <<< $( get_tmux_option " @dracula-git-no-untracked-files" " false" )
11+ IFS=' ' read -r -a show_remote_status <<< $( get_tmux_option " @dracula-git-show-remote-status" " false" )
1112
1213# Get added, modified, updated and deleted files from git status
1314getChanges ()
@@ -110,37 +111,59 @@ getBranch()
110111 fi
111112}
112113
114+ getRemoteInfo ()
115+ {
116+ base=$( git -C $path for-each-ref --format=' %(upstream:short) %(upstream:track)' " $( git -C $path symbolic-ref -q HEAD) " )
117+ remote=$( echo " $base " | cut -d" " -f1)
118+ out=" "
119+
120+ if [ -n " $remote " ]; then
121+ out=" ...$remote "
122+ ahead=$( echo " $base " | grep -E -o ' ahead[ [:digit:]]+' | cut -d" " -f2)
123+ behind=$( echo " $base " | grep -E -o ' behind[ [:digit:]]+' | cut -d" " -f2)
124+
125+ [ -n " $ahead " ] && out+=" +$ahead "
126+ [ -n " $behind " ] && out+=" -$behind "
127+ fi
128+
129+ echo " $out "
130+ }
131+
113132# return the final message for the status bar
114133getMessage ()
115134{
116135 if [ $( checkForGitDir) == " true" ]; then
117136 branch=" $( getBranch) "
118-
137+ output=" "
138+
119139 if [ $( checkForChanges) == " true" ]; then
120140
121141 changes=" $( getChanges) "
122142
123143 if [ " ${hide_status} " == " false" ]; then
124144 if [ $( checkEmptySymbol $diff_symbol ) == " true" ]; then
125- echo " ${changes} $branch "
145+ output= $( echo " ${changes} $branch " )
126146 else
127- echo " $diff_symbol ${changes} $branch "
147+ output= $( echo " $diff_symbol ${changes} $branch " )
128148 fi
129149 else
130150 if [ $( checkEmptySymbol $diff_symbol ) == " true" ]; then
131- echo " $branch "
151+ output= $( echo " $branch " )
132152 else
133- echo " $diff_symbol $branch "
153+ output= $( echo " $diff_symbol $branch " )
134154 fi
135155 fi
136156
137157 else
138158 if [ $( checkEmptySymbol $current_symbol ) == " true" ]; then
139- echo " $branch "
159+ output= $( echo " $branch " )
140160 else
141- echo " $current_symbol $branch "
161+ output= $( echo " $current_symbol $branch " )
142162 fi
143163 fi
164+
165+ [ " $show_remote_status " == " true" ] && output+=$( getRemoteInfo)
166+ echo " $output "
144167 else
145168 echo $no_repo_message
146169 fi
0 commit comments