diff options
| author | Michael Allen <michael@michaelallen.io> | 2015-09-17 10:46:26 +0100 | 
|---|---|---|
| committer | Michael Allen <michael@michaelallen.io> | 2015-09-17 10:46:26 +0100 | 
| commit | 01bcac0242e4b44c796cdd88c1f87c66c5fdf158 (patch) | |
| tree | 8bf82c1a735c8a3a8f5850abe2e5e193bf01cbaf | |
| parent | 3e809c83741cc6466090169404dd0aa2672d29ac (diff) | |
| download | git-sonar-01bcac0242e4b44c796cdd88c1f87c66c5fdf158.tar.gz git-sonar-01bcac0242e4b44c796cdd88c1f87c66c5fdf158.zip | |
Reduce rewording in regexes
Diffstat (limited to '')
| -rwxr-xr-x | radar-base.sh | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/radar-base.sh b/radar-base.sh index 665b30a..a1ea097 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -493,17 +493,23 @@ render_prompt() {    remote_sed=""    local_sed=""    changes_sed="" + +  if_pre="%{([^%{}]{1,}:){0,1}" +  if_post="(:[^%{}]{1,}){0,1}}" +  sed_pre="%{\(\([^%^{^}]*\)\:\)\{0,1\}" +  sed_post="\(\:\([^%^{^}]*\)\)\{0,1\}}" +    if [[ $output =~ ^.*%{remote}.*$ ]]; then      remote_sed="s/%{remote}/$(color_remote_commits)/"    fi    if [[ $PROMPT_FORMAT =~ ^.*%{branch}.*$ ]]; then      branch_sed="s/%{branch}/$(readable_branch_name)/"    fi -  if [[ $PROMPT_FORMAT =~ %{([^%{}]{1,}:){0,1}local(:[^%{}]{1,}){0,1}} ]]; then -    local_sed="s/%{\(\([^%^{^}]*\)\:\)\{0,1\}local\(\:\([^%^{^}]*\)\)\{0,1\}}/\2$(color_local_commits)\4/" +  if [[ $PROMPT_FORMAT =~ ${if_pre}local${if_post} ]]; then +    local_sed="s/${sed_pre}local${sed_post}/\2$(color_local_commits)\4/"    fi -  if [[ $PROMPT_FORMAT =~ %{([^%{}]{1,}:){0,1}changes(:[^%{}]{1,}){0,1}} ]]; then -    changes_sed="s/%{\(\([^%^{^}]*\)\:\)\{0,1\}changes\(\:\([^%^{^}]*\)\)\{0,1\}}/\2$(color_changes_status)\4/" +  if [[ $PROMPT_FORMAT =~ ${if_pre}changes${if_post} ]]; then +    changes_sed="s/${sed_pre}changes${sed_post}/\2$(color_changes_status)\4/"    fi    sed \ | 
