From b1d4db6bf5d2b346dcb3f6a169d91a20d05da110 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Tue, 17 Sep 2013 13:06:06 +1200 Subject: Improve status parsing for SVN a bit --- bash/bashrc.d/prompt.bash | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'bash/bashrc.d/prompt.bash') diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash index 42771c0b..1ad239d9 100644 --- a/bash/bashrc.d/prompt.bash +++ b/bash/bashrc.d/prompt.bash @@ -168,14 +168,27 @@ prompt() { branch=${branch#branches/} branch=${branch%%/*} - # Start collecting working copy state flags - local -a state + # Parse the output of svn info to determine working copy state + local symbol new modified + while read -r symbol _; do + case $symbol in + *'?'*) + new=1 + ;; + *) + modified=1 + ;; + esac + done < <(svn status 2>/dev/null) - # If there are changes in the working directory, add an exclamation - # mark to the state - if [[ $(svn status 2>/dev/null) ]]; then + # Add appropriate state flags + local -a state + if [[ $modified ]]; then state=("${state[@]}" '!') fi + if [[ $new ]]; then + state=("${state[@]}" '?') + fi # Print the state in brackets with an svn: prefix printf '(svn:%s%s)' \ -- cgit v1.2.3