diff options
| author | Michael Allen <michael@michaelallen.io> | 2015-08-06 09:58:13 +0100 | 
|---|---|---|
| committer | Michael Allen <michael@michaelallen.io> | 2015-08-06 09:58:13 +0100 | 
| commit | 6b40c172f04036931886a92c200197ef7bd9917f (patch) | |
| tree | a43cdae1b619cce9f33f5dc068deb39fe88b47ea | |
| parent | 87c8f642278cf82e9c9011413624b64a878b23a9 (diff) | |
| download | git-sonar-6b40c172f04036931886a92c200197ef7bd9917f.tar.gz git-sonar-6b40c172f04036931886a92c200197ef7bd9917f.zip  | |
Provide bash colors for local commit diffs
| -rwxr-xr-x | git-base.sh | 26 | ||||
| -rwxr-xr-x | prompt.sh | 2 | 
2 files changed, 27 insertions, 1 deletions
diff --git a/git-base.sh b/git-base.sh index aca271b..afd4f7e 100755 --- a/git-base.sh +++ b/git-base.sh @@ -370,6 +370,32 @@ zsh_color_changes_status() {    echo $changes  } +bash_color_local_commits() { +  local green_ahead_arrow="\033[1;32m↑\033[0m" +  local red_behind_arrow="\033[1;31m↓\033[0m" +  local yellow_diverged_arrow="\033[1;33m⇵\033[0m" + +  local local_commits="" +  if is_repo; then + +    if remote_branch="$(remote_branch_name)"; then +      local_ahead="$(commits_ahead_of_remote "$remote_branch")" +      local_behind="$(commits_behind_of_remote "$remote_branch")" +      remote_ahead="$(remote_ahead_of_master "$remote_branch")" +      remote_behind="$(remote_behind_of_master "$remote_branch")" + +      if [[ "$local_behind" -gt "0" && "$local_ahead" -gt "0" ]]; then +        local_commits=" $local_behind$yellow_diverged_arrow$local_ahead" +      elif [[ "$local_behind" -gt "0" ]]; then +        local_commits=" $local_behind$red_behind_arrow" +      elif [[ "$local_ahead" -gt "0" ]]; then +        local_commits=" $local_ahead$green_ahead_arrow" +      fi +    fi +  fi +  echo $local_commits +} +  zsh_color_local_commits() {    local ahead_arrow="%{$fg_bold[green]%}↑%{$reset_color%}"    local behind_arrow="%{$fg_bold[red]%}↓%{$reset_color%}" @@ -18,6 +18,6 @@ else    local_behind=""  fi -prompt="$(branch_name) $(zsh_color_local_commits) $(bash_color_changes_status)" +prompt="$(branch_name) $(bash_color_local_commits) $(bash_color_changes_status)"  echo $prompt  | 
