From 6e351cbf7a427bd12365c37b046b0b11bde9cf09 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Thu, 25 Aug 2016 11:25:00 +1200 Subject: Show REBASE,MERGE etc in Git prompt Again pretty much pilfered from the contrib git prompt script in the Git source --- bash/bashrc.d/prompt.bash | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bash/bashrc.d') 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 -- cgit v1.2.3