aboutsummaryrefslogtreecommitdiff
path: root/bash/bashrc.d/prompt.bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2013-07-31 17:43:16 +1200
committerTom Ryder <tom@sanctum.geek.nz>2013-07-31 17:43:16 +1200
commit46523532a61c83fba40469a85e723ffa180e1f00 (patch)
treeb2f89f99379d3017a0d1e919c0e1d938944c5c42 /bash/bashrc.d/prompt.bash
parentExplicitly check for setup command existence (diff)
downloaddotfiles-46523532a61c83fba40469a85e723ffa180e1f00.tar.gz
dotfiles-46523532a61c83fba40469a85e723ffa180e1f00.zip
Speed up SVN prompt with only one call to svn info
Keep the output of `svn info` in a new local variable and use Bash herestrings to read the repository URL and root from that variable
Diffstat (limited to 'bash/bashrc.d/prompt.bash')
-rw-r--r--bash/bashrc.d/prompt.bash11
1 files changed, 6 insertions, 5 deletions
diff --git a/bash/bashrc.d/prompt.bash b/bash/bashrc.d/prompt.bash
index 0d477cc7..160ea186 100644
--- a/bash/bashrc.d/prompt.bash
+++ b/bash/bashrc.d/prompt.bash
@@ -2,7 +2,7 @@
prompt() {
local -i ret=$?
local -i colors=$(tput colors 2>/dev/null)
- local color reset branch state url root
+ local color reset branch state info url root
if [[ $colors -ge 256 ]]; then
color='\[\e[38;5;10m\]'
@@ -71,10 +71,11 @@ prompt() {
if ! svn info &>/dev/null; then
return 1
fi
- url="$(svn info 2>/dev/null | \
- awk -F': ' '$1 == "URL" {print $2}')"
- root="$(svn info 2>/dev/null | \
- awk -F': ' '$1 == "Repository Root" {print $2}')"
+ info="$(svn info 2>/dev/null)"
+ url="$(awk -F': ' '$1 == "URL" {print $2}' \
+ <<<"$info")"
+ root="$(awk -F': ' '$1 == "Repository Root" {print $2}' \
+ <<<"$info")"
branch=${url/$root}
branch=${branch#/}
branch=${branch#branches/}