aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-21 12:36:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-21 12:36:09 +1200
commit5ce5d0813c34ce919a7636ef65a673b40bed77ef (patch)
treeba12defc5b2a4d25b880b3b0898a6e4583335647
parentMerge branch 'master' into openbsd (diff)
downloaddotfiles-5ce5d0813c34ce919a7636ef65a673b40bed77ef.tar.gz
dotfiles-5ce5d0813c34ce919a7636ef65a673b40bed77ef.zip
Port Bash Git prompt changes to pdksh
-rw-r--r--pdksh/pdkshrc.d/prompt.pdksh22
1 files changed, 19 insertions, 3 deletions
diff --git a/pdksh/pdkshrc.d/prompt.pdksh b/pdksh/pdkshrc.d/prompt.pdksh
index 2486373d..f9dfa584 100644
--- a/pdksh/pdkshrc.d/prompt.pdksh
+++ b/pdksh/pdkshrc.d/prompt.pdksh
@@ -100,14 +100,30 @@ prompt() {
# Collect symbols representing repository state
typeset 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)