aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-09-21 18:16:07 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-09-21 18:16:07 +1200
commit0520ab0de25774a8f690c8a51c2e7bc37aeb4edc (patch)
tree337b9c92071c94f7b1b615fb4a5eeb368bed6ce2 /bash
parentSome more opts/refinements for git prompt (diff)
downloaddotfiles-0520ab0de25774a8f690c8a51c2e7bc37aeb4edc.tar.gz
dotfiles-0520ab0de25774a8f690c8a51c2e7bc37aeb4edc.zip
Enhance parsing of hg status a bit too
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/prompt.bash19
1 files changed, 16 insertions, 3 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index cc750934..e2dfdc87 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -108,11 +108,24 @@ prompt() {
# Start collecting working copy state flags
local -a state
- # If there are changes in the tree, add an exclamation mark to the
- # state
- if [[ $(hg status 2>/dev/null) ]]; then
+ # Safely read status from ``git porcelain''
+ local line modified untracked
+ while IFS= read -d $'\0' -r line _; do
+ if [[ $line == '?'* ]]; then
+ untracked=1
+ else
+ modified=1
+ fi
+ done < <(hg status -0 2>/dev/null)
+
+ # Build state array from status output flags
+ local -a state
+ if [[ $modified ]]; then
state=("${state[@]}" '!')
fi
+ if [[ $untracked ]]; then
+ state=("${state[@]}" '?')
+ fi
# Print the status in brackets with an hg: prefix
local IFS=