From d5dbddf68c45dfff380d6e6767de401054024a19 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 19 Aug 2015 09:49:20 +0100 Subject: Remove unnecessary subshells from bash prompt In the zsh prompt we need to use '%s' on the printf to prevent the `${fg_bold[]}` expressions from expanding before the colors have been loaded in. In the bash prompt this is unnecessary as the \\033 codes are base control characters, and so have no dependency they rely on. --- git-base.sh | 6 +++--- prompt.bash | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/git-base.sh b/git-base.sh index 239e2bd..0fee704 100755 --- a/git-base.sh +++ b/git-base.sh @@ -333,7 +333,7 @@ bash_color_changes_status() { changes="$staged_changes$conflicted_changes$unstaged_changes$untracked_changes" fi - printf %s "$changes" + printf "$changes" } zsh_color_changes_status() { @@ -394,7 +394,7 @@ bash_color_local_commits() { local_commits="$separator$local_ahead$green_ahead_arrow" fi fi - printf %s "$local_commits" + printf "$local_commits" } zsh_color_local_commits() { @@ -442,7 +442,7 @@ bash_color_remote_commits() { remote="upstream $not_upstream " fi - printf %s "$remote" + printf "$remote" } zsh_color_remote_commits() { diff --git a/prompt.bash b/prompt.bash index 410989c..e39a1b1 100755 --- a/prompt.bash +++ b/prompt.bash @@ -4,7 +4,12 @@ dot="$(cd "$(dirname "$0")"; pwd)" source "$dot/git-base.sh" if is_repo; then - git_prefix="\033[1;30mgit:(\033[0m" - git_suffix="\033[1;30m)\033[0m" - printf " $git_prefix$(bash_color_remote_commits;readable_branch_name;bash_color_local_commits)$git_suffix$(bash_color_changes_status)" + printf " \033[1;30mgit:(\033[0m" + bash_color_remote_commits + printf "\033[0;37m" + readable_branch_name + printf "\033[0m" + bash_color_local_commits + printf "\033[1;30m)\033[0m" + bash_color_changes_status fi -- cgit v1.2.3