aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-31 13:42:46 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-31 13:42:46 +1200
commitc5828c451e8e43558a9cbce2a0dbafc5db8c7154 (patch)
tree2195ba046b7f216181bdfa23aebc26956b830a6d /bash/bashrc.d
parent2e783635b47b7b7ed2d04830cd3193f19de8cbbb (diff)
downloaddotfiles-c5828c451e8e43558a9cbce2a0dbafc5db8c7154.tar.gz
dotfiles-c5828c451e8e43558a9cbce2a0dbafc5db8c7154.zip
Efficiency tweaks for Subversion prompt
Diffstat (limited to 'bash/bashrc.d')
-rw-r--r--bash/bashrc.d/prompt.bash28
1 files changed, 11 insertions, 17 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 5abcf4d8..b95cf92a 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -168,12 +168,8 @@ prompt() {
local key value url root
while [[ -z $url || -z $root ]] && IFS=: read -r key value ; do
case $key in
- 'URL')
- url=${value## }
- ;;
- 'Repository Root')
- root=${value## }
- ;;
+ 'URL') url=${value## } ;;
+ 'Repository Root') root=${value## } ;;
esac
done < <(svn info 2>/dev/null)
@@ -193,22 +189,20 @@ prompt() {
# Parse the output of svn status to determine working copy state
local symbol
local -i modified untracked
- while read -r symbol _ ; do
- if [[ $symbol == *'?'* ]] ; then
- untracked=1
- else
- modified=1
- fi
+ while ((!modified || !untracked)) && read -r symbol _ ; do
+ case $symbol in
+ *\?*) untracked=1 ;;
+ *) modified=1 ;;
+ esac
done < <(svn status 2>/dev/null)
# Add appropriate state flags
- local -a state
- ((modified)) && state[${#state[@]}]='!'
- ((untracked)) && state[${#state[@]}]='?'
+ local state
+ ((modified)) && state=${state}'!'
+ ((untracked)) && state=${state}'?'
# Print the state in brackets with an svn: prefix
- (IFS= ; printf '(svn:%s%s)' \
- "${branch:-unknown}" "${state[*]}")
+ printf '(svn:%s%s)' "${branch:-unknown}" "$state"
;;
# VCS wrapper prompt function; print the first relevant prompt, if any