diff options
Diffstat (limited to 'bash')
-rw-r--r-- | bash/bashrc.d/prompt.bash | 19 |
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= |