aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-21 12:34:02 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-21 12:34:02 +1200
commit739776b45771ae0c67a8b810ce224eba0de29737 (patch)
treeb1aff78cbfc2da431d83d50de5fe92571dda102c /bash/bashrc.d/prompt.bash
parentMerge branch 'master' into openbsd (diff)
parentAdd some upstream checking to Git prompt (diff)
downloaddotfiles-739776b45771ae0c67a8b810ce224eba0de29737.tar.gz
dotfiles-739776b45771ae0c67a8b810ce224eba0de29737.zip
Merge branch 'master' into openbsd
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash22
1 files changed, 19 insertions, 3 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index dca34928..1e8c568d 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -127,14 +127,30 @@ prompt() {
# Collect symbols representing repository state
local state
+
+ # Upstream HEAD has commits after local HEAD; we're "behind"
+ (($(git rev-list --count 'HEAD..@{u}' 2>/dev/null) > 0)) &&
+ state=${state}\<
+
+ # Local HEAD has commits after upstream HEAD; we're "ahead"
+ (($(git rev-list --count '@{u}..HEAD' 2>/dev/null) > 0)) &&
+ state=${state}\>
+
+ # Tracked files are modified
git diff-files --quiet ||
- state=${state}!
+ state=${state}\!
+
+ # Changes are staged
git diff-index --cached --quiet HEAD ||
- state=${state}+
+ state=${state}\+
+
+ # There are some untracked and unignored files
[[ -n $(git ls-files --others --exclude-standard) ]] &&
state=${state}\?
+
+ # There are stashed changes
git rev-parse --quiet --verify refs/stash >/dev/null &&
- state=${state}^
+ state=${state}\^
# Print the status in brackets; add a git: prefix only if there
# might be another VCS prompt (because PROMPT_VCS is set)