From 0ef61eaf131888c873a2df1dccb04b34bb7e7383 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 21 Aug 2016 11:32:17 +1200 Subject: Add bash prompt Git fixes into pdksh --- pdksh/pdkshrc.d/prompt.pdksh | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'pdksh') diff --git a/pdksh/pdkshrc.d/prompt.pdksh b/pdksh/pdkshrc.d/prompt.pdksh index 71e952a0..2486373d 100644 --- a/pdksh/pdkshrc.d/prompt.pdksh +++ b/pdksh/pdkshrc.d/prompt.pdksh @@ -95,21 +95,19 @@ prompt() { fi branch=${branch##*/} + # Refresh index so e.g. git-diff-files(1) is accurate + git update-index --refresh >/dev/null + + # Collect symbols representing repository state typeset state - if ! git diff-files --quiet ; then - # Two exclamation marks, as that's how you get a literal "!" in - # a pdksh PS1 + git diff-files --quiet || state=${state}!! - fi - if ! git diff-index --cached --quiet HEAD ; then + git diff-index --cached --quiet HEAD || state=${state}+ - fi - if [[ -n $(git ls-files --others --exclude-standard) ]] ; then - state=${state}? - fi - if git rev-parse --verify refs/stash >/dev/null 2>&1 ; then + [[ -n $(git ls-files --others --exclude-standard) ]] && + state=${state}\? + git rev-parse --quiet --verify refs/stash >/dev/null && state=${state}^ - fi # Print the status in brackets; add a git: prefix only if there # might be another VCS prompt (because PROMPT_VCS is set) -- cgit v1.2.3