浏览代码

feat(agnoster): add remote-tracking status to prompt (#7209)

Dan Wallis 2 年之前
父节点
当前提交
c189e8b40c
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      themes/agnoster.zsh-theme

+ 11 - 0
themes/agnoster.zsh-theme

@@ -116,6 +116,17 @@ prompt_git() {
       prompt_segment green $CURRENT_FG
     fi
 
+    local ahead behind
+    ahead=$(git log --oneline @{upstream}.. 2>/dev/null)
+    behind=$(git log --oneline ..@{upstream} 2>/dev/null)
+    if [[ -n "$ahead" ]] && [[ -n "$behind" ]]; then
+      PL_BRANCH_CHAR=$'\u21c5'
+    elif [[ -n "$ahead" ]]; then
+      PL_BRANCH_CHAR=$'\u21b1'
+    elif [[ -n "$behind" ]]; then
+      PL_BRANCH_CHAR=$'\u21b0'
+    fi
+
     if [[ -e "${repo_path}/BISECT_LOG" ]]; then
       mode=" <B>"
     elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then