]> git.rmz.io Git - dotfiles.git/blobdiff - zsh/lib/prompt.zsh
zsh/prompt: print upstream information
[dotfiles.git] / zsh / lib / prompt.zsh
index a1be82b931f4c2207fad384b7dc63c7246471977..9789ed735dbd7856f6e6d6aa296f6bca2df64481 100644 (file)
@@ -51,6 +51,7 @@ git_prompt_status() {
     if [[ "$line" == \#\ * ]]; then
       [[ "$line" =~ '# branch.oid ([0-9a-f]+)' ]]         && oid=$match[1]
       [[ "$line" =~ '# branch.head (.*)' ]]               && head=$match[1]
     if [[ "$line" == \#\ * ]]; then
       [[ "$line" =~ '# branch.oid ([0-9a-f]+)' ]]         && oid=$match[1]
       [[ "$line" =~ '# branch.head (.*)' ]]               && head=$match[1]
+      [[ "$line" =~ '# branch.upstream (.*)' ]]           && upstream=$match[1]
       [[ "$line" =~ '# branch.ab \+([0-9]+) -([0-9]+)' ]] && ahead=$match[1] && behind=$match[2]
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
       [[ "$line" =~ '# branch.ab \+([0-9]+) -([0-9]+)' ]] && ahead=$match[1] && behind=$match[2]
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
@@ -62,6 +63,7 @@ git_prompt_status() {
       [[ "$line" == 2\ R[.MTD]\ * ]]      && (( renamed++ ))
 
       # work tree
       [[ "$line" == 2\ R[.MTD]\ * ]]      && (( renamed++ ))
 
       # work tree
+      [[ "$line" == 1\ [.MARCT]A\ * ]]    && (( added++ , modified++ ))  # intend-to-add
       [[ "$line" == 1\ [.MARCT]M\ * ]]    && (( modified++ ))
       [[ "$line" == 1\ [.MARCT]D\ * ]]    && (( deleted_wt++ ))
       [[ "$line" == \?\ * ]]              && (( untracked++ ))
       [[ "$line" == 1\ [.MARCT]M\ * ]]    && (( modified++ ))
       [[ "$line" == 1\ [.MARCT]D\ * ]]    && (( deleted_wt++ ))
       [[ "$line" == \?\ * ]]              && (( untracked++ ))
@@ -78,6 +80,7 @@ git_prompt_status() {
 
   # Format upstream
   local upstream_str
 
   # Format upstream
   local upstream_str
+  [[ -z "$upstream" ]] && upstream_str+="%{$fg[blue]%} Ɇ"
   (( ahead  > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead"
   (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind"
   git_status+="$upstream_str"
   (( ahead  > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead"
   (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind"
   git_status+="$upstream_str"