Skip to content

Commit e8c68ca

Browse files
Show commits ahead of upstream and behind upstream in git prompt
1 parent 385f336 commit e8c68ca

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scripts/git-prompt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ changes() {
3030
STAGED="$(git diff --cached --name-only 2>/dev/null | wc --lines)s"
3131
WORKTREE="$(git diff --name-only 2>/dev/null | wc --lines)w"
3232
UNTRACKED="$(git ls-files --others --exclude-standard 2>/dev/null | wc --lines)u"
33-
echo "${STAGED}${WORKTREE}${UNTRACKED}" | sed -E ':1; s/(^|[^0-9])0[swu]/\1/g; t1;'
33+
AHEAD_BEHIND="$(git rev-list --left-right --count @...@{u} | sed -E 's/^([0-9]+)/\1a/; s/\s+([0-9]+)$/\1b/')"
34+
echo "${STAGED}${WORKTREE}${UNTRACKED}${AHEAD_BEHIND}" | sed -E ':1; s/(^|[^0-9])0[swuab]/\1/g; t1;'
3435
}
3536

3637
if ! is_git_repo; then

0 commit comments

Comments
 (0)