aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-25 11:25:00 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-25 11:25:00 +1200
commit6e351cbf7a427bd12365c37b046b0b11bde9cf09 (patch)
treed456a8827e87198f470b082e6189a8e6e698c654
parentShow tag name in Git prompt if commit is tagged (diff)
downloaddotfiles-6e351cbf7a427bd12365c37b046b0b11bde9cf09.tar.gz
dotfiles-6e351cbf7a427bd12365c37b046b0b11bde9cf09.zip
Show REBASE,MERGE etc in Git prompt
Again pretty much pilfered from the contrib git prompt script in the Git source
-rw-r--r--bash/bashrc.d/prompt.bash18
1 files changed, 16 insertions, 2 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index d981bccf..cd029a2e 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -114,6 +114,19 @@ prompt() {
# Refresh index so e.g. git-diff-files(1) is accurate
git update-index --refresh >/dev/null
+ # Check various files in .git to flag processes
+ local proc
+ [[ -d .git/rebase-merge || -d .git/rebase-apply ]] &&
+ proc=${proc:+$proc,}'REBASE'
+ [[ -f .git/MERGE_HEAD ]] &&
+ proc=${proc:+$proc,}'MERGE'
+ [[ -f .git/CHERRY_PICK_HEAD ]] &&
+ proc=${proc:+$proc,}'PICK'
+ [[ -f .git/REVERT_HEAD ]] &&
+ proc=${proc:+$proc,}'REVERT'
+ [[ -f .git/BISECT_LOG ]] &&
+ proc=${proc:+$proc,}'BISECT'
+
# Collect symbols representing repository state
local state
@@ -146,8 +159,9 @@ prompt() {
# Print the status in brackets; add a git: prefix only if there
# might be another VCS prompt (because PROMPT_VCS is set)
- printf '(%s%s%s)' \
- "${PROMPT_VCS:+git:}" "${branch:-unknown}" "$state"
+ printf '(%s%s%s%s)' \
+ "${PROMPT_VCS:+git:}" "${branch:-unknown}" \
+ "${proc:+:$proc}" "$state"
;;
# Subversion prompt function