diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2013-07-31 17:43:16 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2013-07-31 17:43:16 +1200 |
commit | 46523532a61c83fba40469a85e723ffa180e1f00 (patch) | |
tree | b2f89f99379d3017a0d1e919c0e1d938944c5c42 /bash/bashrc.d/prompt.bash | |
parent | Explicitly check for setup command existence (diff) | |
download | dotfiles-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.bash | 11 |
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/} |