From 637b5d5534469ebb15826139e1b3df12a1cc9309 Mon Sep 17 00:00:00 2001 From: Reinaldo Colina Date: Thu, 27 Aug 2015 12:14:13 -0700 Subject: issue-17: Add arguments to make the prompt shorter --- radar-base.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index b7074d8..a2f5115 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -1,3 +1,6 @@ +IS_MINIMAL='--minimal' +NO_REMOTE_STATUS='--no-remote-status' + dot_git="" cwd="" remote="" @@ -469,3 +472,17 @@ zsh_color_remote_commits() { printf %s "$remote" } + +show_git_label() { + if [[ $@ == *$IS_MINIMAL* ]]; then + return 1 # don't show the git label + fi + return 0 +} + +show_remote_status() { + if [[ $@ == *$NO_REMOTE_STATUS* ]]; then + return 1 # don't show the git remote status + fi + return 0 +} -- cgit v1.2.3 From 93dad96832a59d3d7f6ac6580cabf0202b387ffe Mon Sep 17 00:00:00 2001 From: Reinaldo Colina Date: Fri, 28 Aug 2015 13:55:37 -0700 Subject: Removing --minimal arg implementation - Dealing with the git: prefix will be done in a separate pull request - The new --no-remote-status arg remains --- radar-base.sh | 9 --------- 1 file changed, 9 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index a2f5115..d019629 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -1,4 +1,3 @@ -IS_MINIMAL='--minimal' NO_REMOTE_STATUS='--no-remote-status' dot_git="" @@ -472,14 +471,6 @@ zsh_color_remote_commits() { printf %s "$remote" } - -show_git_label() { - if [[ $@ == *$IS_MINIMAL* ]]; then - return 1 # don't show the git label - fi - return 0 -} - show_remote_status() { if [[ $@ == *$NO_REMOTE_STATUS* ]]; then return 1 # don't show the git remote status -- cgit v1.2.3 From 3c7b0841158b23be74f796c84880ec01a91cc5ad Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 13:25:03 +0100 Subject: Make zsh remote commit colors configurable --- radar-base.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index d019629..7d5db56 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -4,6 +4,15 @@ dot_git="" cwd="" remote="" +prepare_zsh_colors() { + ZSH_COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_ZSH_REMOTE_AHEAD:-$fg_bold[green]}" + ZSH_COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_ZSH_REMOTE_BEHIND:-$fg_bold[red]}" + ZSH_COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_ZSH_REMOTE_DIVERGED:-$fg_bold[yellow]}" + ZSH_COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_ZSH_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" + + ZSH_RESET_COLOR="${GIT_RADAR_COLOR_ZSH_RESET:-$reset_color}" +} + in_current_dir() { local wd="$(pwd)" if [[ "$wd" == $cwd ]]; then @@ -448,11 +457,13 @@ bash_color_remote_commits() { } zsh_color_remote_commits() { + prepare_zsh_colors + local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master - local green_ahead_arrow="%{$fg_bold[green]%}←%{$reset_color%}" - local red_behind_arrow="%{$fg_bold[red]%}→%{$reset_color%}" - local yellow_diverged_arrow="%{$fg_bold[yellow]%}⇄%{$reset_color%}" - local not_upstream="%{$fg_bold[red]%}⚡%{$reset_color%}" + local green_ahead_arrow="%{$ZSH_COLOR_REMOTE_AHEAD%}←%{$ZSH_RESET_COLOR%}" + local red_behind_arrow="%{$ZSH_COLOR_REMOTE_BEHIND%}→%{$ZSH_RESET_COLOR%}" + local yellow_diverged_arrow="%{$ZSH_COLOR_REMOTE_DIVERGED%}⇄%{$ZSH_RESET_COLOR%}" + local not_upstream="%{$ZSH_COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$ZSH_RESET_COLOR%}" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From 0133ca499824f4d41ef9bd9a847934bd66fa32cd Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 13:43:59 +0100 Subject: Rename reset color and move color setup --- radar-base.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 7d5db56..ee45300 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -5,12 +5,14 @@ cwd="" remote="" prepare_zsh_colors() { + autoload colors && colors + ZSH_COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_ZSH_REMOTE_AHEAD:-$fg_bold[green]}" ZSH_COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_ZSH_REMOTE_BEHIND:-$fg_bold[red]}" ZSH_COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_ZSH_REMOTE_DIVERGED:-$fg_bold[yellow]}" ZSH_COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_ZSH_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" - ZSH_RESET_COLOR="${GIT_RADAR_COLOR_ZSH_RESET:-$reset_color}" + ZSH_RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_ZSH_REMOTE_RESET:-$reset_color}" } in_current_dir() { @@ -457,13 +459,11 @@ bash_color_remote_commits() { } zsh_color_remote_commits() { - prepare_zsh_colors - local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master - local green_ahead_arrow="%{$ZSH_COLOR_REMOTE_AHEAD%}←%{$ZSH_RESET_COLOR%}" - local red_behind_arrow="%{$ZSH_COLOR_REMOTE_BEHIND%}→%{$ZSH_RESET_COLOR%}" - local yellow_diverged_arrow="%{$ZSH_COLOR_REMOTE_DIVERGED%}⇄%{$ZSH_RESET_COLOR%}" - local not_upstream="%{$ZSH_COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$ZSH_RESET_COLOR%}" + local green_ahead_arrow="%{$ZSH_COLOR_REMOTE_AHEAD%}←%{$ZSH_RESET_COLOR_REMOTE%}" + local red_behind_arrow="%{$ZSH_COLOR_REMOTE_BEHIND%}→%{$ZSH_RESET_COLOR_REMOTE%}" + local yellow_diverged_arrow="%{$ZSH_COLOR_REMOTE_DIVERGED%}⇄%{$ZSH_RESET_COLOR_REMOTE%}" + local not_upstream="%{$ZSH_COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$ZSH_RESET_COLOR_REMOTE%}" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From d3955bde0d873edbd70c8902954c9d3761a3b935 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 13:44:36 +0100 Subject: Make zsh local commit colors configurable --- radar-base.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index ee45300..99e8a23 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -12,7 +12,13 @@ prepare_zsh_colors() { ZSH_COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_ZSH_REMOTE_DIVERGED:-$fg_bold[yellow]}" ZSH_COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_ZSH_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" + ZSH_COLOR_LOCAL_AHEAD="${GIT_RADAR_COLOR_ZSH_LOCAL_AHEAD:-$fg_bold[green]}" + ZSH_COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_ZSH_LOCAL_BEHIND:-$fg_bold[red]}" + ZSH_COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_ZSH_LOCAL_DIVERGED:-$fg_bold[yellow]}" + + ZSH_RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_ZSH_LOCAL_RESET:-$reset_color}" ZSH_RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_ZSH_REMOTE_RESET:-$reset_color}" + ZSH_RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_ZSH_CHANGES_RESET:-$reset_color}" } in_current_dir() { @@ -413,9 +419,9 @@ bash_color_local_commits() { zsh_color_local_commits() { local separator="${1:- }" - local ahead_arrow="%{$fg_bold[green]%}↑%{$reset_color%}" - local behind_arrow="%{$fg_bold[red]%}↓%{$reset_color%}" - local diverged_arrow="%{$fg_bold[yellow]%}⇵%{$reset_color%}" + local ahead_arrow="%{$ZSH_COLOR_LOCAL_AHEAD%}↑%{$ZSH_RESET_COLOR_LOCAL%}" + local behind_arrow="%{$ZSH_COLOR_LOCAL_BEHIND%}↓%{$ZSH_RESET_COLOR_LOCAL%}" + local diverged_arrow="%{$ZSH_COLOR_LOCAL_DIVERGED%}⇵%{$ZSH_RESET_COLOR_LOCAL%}" local local_commits="" if remote_branch="$(remote_branch_name)"; then -- cgit v1.2.3 From f7bb14861a4ab034345d6830f82420433a6dab17 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 13:55:22 +0100 Subject: Make zsh changes colors configurable --- radar-base.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 99e8a23..798c6e1 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -16,6 +16,11 @@ prepare_zsh_colors() { ZSH_COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_ZSH_LOCAL_BEHIND:-$fg_bold[red]}" ZSH_COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_ZSH_LOCAL_DIVERGED:-$fg_bold[yellow]}" + ZSH_COLOR_CHANGES_STAGED="${GIT_RADAR_COLOR_ZSH_CHANGES_STAGED:-$fg_bold[green]}" + ZSH_COLOR_CHANGES_UNSTAGED="${GIT_RADAR_COLOR_ZSH_CHANGES_UNSTAGED:-$fg_bold[red]}" + ZSH_COLOR_CHANGES_CONFLICTED="${GIT_RADAR_COLOR_ZSH_CHANGES_CONFLICTED:-$fg_bold[yellow]}" + ZSH_COLOR_CHANGES_UNTRACKED="${GIT_RADAR_COLOR_ZSH_CHANGES_UNTRACKED:-$fg_bold[white]}" + ZSH_RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_ZSH_LOCAL_RESET:-$reset_color}" ZSH_RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_ZSH_REMOTE_RESET:-$reset_color}" ZSH_RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_ZSH_CHANGES_RESET:-$reset_color}" @@ -362,11 +367,11 @@ zsh_color_changes_status() { local changes="" if [[ -n "$porcelain" ]]; then - local staged_prefix="%{$fg_bold[green]%}" - local unstaged_prefix="%{$fg_bold[red]%}" - local conflicted_prefix="%{$fg_bold[yellow]%}" - local untracked_prefix="%{$fg_bold[white]%}" - local suffix="%{$reset_color%}" + local staged_prefix="%{$ZSH_COLOR_CHANGES_STAGED%}" + local unstaged_prefix="%{$ZSH_COLOR_CHANGES_UNSTAGED%}" + local conflicted_prefix="%{$ZSH_COLOR_CHANGES_CONFLICTED%}" + local untracked_prefix="%{$ZSH_COLOR_CHANGES_UNTRACKED%}" + local suffix="%{$ZSH_RESET_COLOR_CHANGES%}" local staged_changes="$(staged_status "$porcelain" "$staged_prefix" "$suffix")" local unstaged_changes="$(unstaged_status "$porcelain" "$unstaged_prefix" "$suffix")" -- cgit v1.2.3 From 026ae4fdb3253946707a66448f65d4297c652414 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 14:10:16 +0100 Subject: No need for separate color vars --- radar-base.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 798c6e1..2702b8e 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -7,23 +7,23 @@ remote="" prepare_zsh_colors() { autoload colors && colors - ZSH_COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_ZSH_REMOTE_AHEAD:-$fg_bold[green]}" - ZSH_COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_ZSH_REMOTE_BEHIND:-$fg_bold[red]}" - ZSH_COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_ZSH_REMOTE_DIVERGED:-$fg_bold[yellow]}" - ZSH_COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_ZSH_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" + COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}" + COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}" + COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}" + COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" - ZSH_COLOR_LOCAL_AHEAD="${GIT_RADAR_COLOR_ZSH_LOCAL_AHEAD:-$fg_bold[green]}" - ZSH_COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_ZSH_LOCAL_BEHIND:-$fg_bold[red]}" - ZSH_COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_ZSH_LOCAL_DIVERGED:-$fg_bold[yellow]}" + COLOR_LOCAL_AHEAD="${GIT_RADAR_COLOR_LOCAL_AHEAD:-$fg_bold[green]}" + COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_LOCAL_BEHIND:-$fg_bold[red]}" + COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_LOCAL_DIVERGED:-$fg_bold[yellow]}" - ZSH_COLOR_CHANGES_STAGED="${GIT_RADAR_COLOR_ZSH_CHANGES_STAGED:-$fg_bold[green]}" - ZSH_COLOR_CHANGES_UNSTAGED="${GIT_RADAR_COLOR_ZSH_CHANGES_UNSTAGED:-$fg_bold[red]}" - ZSH_COLOR_CHANGES_CONFLICTED="${GIT_RADAR_COLOR_ZSH_CHANGES_CONFLICTED:-$fg_bold[yellow]}" - ZSH_COLOR_CHANGES_UNTRACKED="${GIT_RADAR_COLOR_ZSH_CHANGES_UNTRACKED:-$fg_bold[white]}" + COLOR_CHANGES_STAGED="${GIT_RADAR_COLOR_CHANGES_STAGED:-$fg_bold[green]}" + COLOR_CHANGES_UNSTAGED="${GIT_RADAR_COLOR_CHANGES_UNSTAGED:-$fg_bold[red]}" + COLOR_CHANGES_CONFLICTED="${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-$fg_bold[yellow]}" + COLOR_CHANGES_UNTRACKED="${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-$fg_bold[white]}" - ZSH_RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_ZSH_LOCAL_RESET:-$reset_color}" - ZSH_RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_ZSH_REMOTE_RESET:-$reset_color}" - ZSH_RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_ZSH_CHANGES_RESET:-$reset_color}" + RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_LOCAL_RESET:-$reset_color}" + RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_REMOTE_RESET:-$reset_color}" + RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_CHANGES_RESET:-$reset_color}" } in_current_dir() { @@ -367,11 +367,11 @@ zsh_color_changes_status() { local changes="" if [[ -n "$porcelain" ]]; then - local staged_prefix="%{$ZSH_COLOR_CHANGES_STAGED%}" - local unstaged_prefix="%{$ZSH_COLOR_CHANGES_UNSTAGED%}" - local conflicted_prefix="%{$ZSH_COLOR_CHANGES_CONFLICTED%}" - local untracked_prefix="%{$ZSH_COLOR_CHANGES_UNTRACKED%}" - local suffix="%{$ZSH_RESET_COLOR_CHANGES%}" + local staged_prefix="%{$COLOR_CHANGES_STAGED%}" + local unstaged_prefix="%{$COLOR_CHANGES_UNSTAGED%}" + local conflicted_prefix="%{$COLOR_CHANGES_CONFLICTED%}" + local untracked_prefix="%{$COLOR_CHANGES_UNTRACKED%}" + local suffix="%{$RESET_COLOR_CHANGES%}" local staged_changes="$(staged_status "$porcelain" "$staged_prefix" "$suffix")" local unstaged_changes="$(unstaged_status "$porcelain" "$unstaged_prefix" "$suffix")" @@ -424,9 +424,9 @@ bash_color_local_commits() { zsh_color_local_commits() { local separator="${1:- }" - local ahead_arrow="%{$ZSH_COLOR_LOCAL_AHEAD%}↑%{$ZSH_RESET_COLOR_LOCAL%}" - local behind_arrow="%{$ZSH_COLOR_LOCAL_BEHIND%}↓%{$ZSH_RESET_COLOR_LOCAL%}" - local diverged_arrow="%{$ZSH_COLOR_LOCAL_DIVERGED%}⇵%{$ZSH_RESET_COLOR_LOCAL%}" + local ahead_arrow="%{$COLOR_LOCAL_AHEAD%}↑%{$RESET_COLOR_LOCAL%}" + local behind_arrow="%{$COLOR_LOCAL_BEHIND%}↓%{$RESET_COLOR_LOCAL%}" + local diverged_arrow="%{$COLOR_LOCAL_DIVERGED%}⇵%{$RESET_COLOR_LOCAL%}" local local_commits="" if remote_branch="$(remote_branch_name)"; then @@ -471,10 +471,10 @@ bash_color_remote_commits() { zsh_color_remote_commits() { local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master - local green_ahead_arrow="%{$ZSH_COLOR_REMOTE_AHEAD%}←%{$ZSH_RESET_COLOR_REMOTE%}" - local red_behind_arrow="%{$ZSH_COLOR_REMOTE_BEHIND%}→%{$ZSH_RESET_COLOR_REMOTE%}" - local yellow_diverged_arrow="%{$ZSH_COLOR_REMOTE_DIVERGED%}⇄%{$ZSH_RESET_COLOR_REMOTE%}" - local not_upstream="%{$ZSH_COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$ZSH_RESET_COLOR_REMOTE%}" + local green_ahead_arrow="%{$COLOR_REMOTE_AHEAD%}←%{$RESET_COLOR_REMOTE%}" + local red_behind_arrow="%{$COLOR_REMOTE_BEHIND%}→%{$RESET_COLOR_REMOTE%}" + local yellow_diverged_arrow="%{$COLOR_REMOTE_DIVERGED%}⇄%{$RESET_COLOR_REMOTE%}" + local not_upstream="%{$COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$RESET_COLOR_REMOTE%}" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From 8b132d8922ab7aec4446842b630299dfd7f6e8e3 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 14:28:27 +0100 Subject: Small refactor to move zero length escaping characters into one location --- radar-base.sh | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 2702b8e..8951b43 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -7,23 +7,23 @@ remote="" prepare_zsh_colors() { autoload colors && colors - COLOR_REMOTE_AHEAD="${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}" - COLOR_REMOTE_BEHIND="${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}" - COLOR_REMOTE_DIVERGED="${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}" - COLOR_REMOTE_NOT_UPSTREAM="${GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}" + COLOR_REMOTE_AHEAD="%{${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}%}" + COLOR_REMOTE_BEHIND="%{${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}%}" + COLOR_REMOTE_DIVERGED="%{${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}%}" + COLOR_REMOTE_NOT_UPSTREAM="%{${GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM:-$fg_bold[red]}%}" - COLOR_LOCAL_AHEAD="${GIT_RADAR_COLOR_LOCAL_AHEAD:-$fg_bold[green]}" - COLOR_LOCAL_BEHIND="${GIT_RADAR_COLOR_LOCAL_BEHIND:-$fg_bold[red]}" - COLOR_LOCAL_DIVERGED="${GIT_RADAR_COLOR_LOCAL_DIVERGED:-$fg_bold[yellow]}" + COLOR_LOCAL_AHEAD="%{${GIT_RADAR_COLOR_LOCAL_AHEAD:-$fg_bold[green]}%}" + COLOR_LOCAL_BEHIND="%{${GIT_RADAR_COLOR_LOCAL_BEHIND:-$fg_bold[red]}%}" + COLOR_LOCAL_DIVERGED="%{${GIT_RADAR_COLOR_LOCAL_DIVERGED:-$fg_bold[yellow]}%}" - COLOR_CHANGES_STAGED="${GIT_RADAR_COLOR_CHANGES_STAGED:-$fg_bold[green]}" - COLOR_CHANGES_UNSTAGED="${GIT_RADAR_COLOR_CHANGES_UNSTAGED:-$fg_bold[red]}" - COLOR_CHANGES_CONFLICTED="${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-$fg_bold[yellow]}" - COLOR_CHANGES_UNTRACKED="${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-$fg_bold[white]}" + COLOR_CHANGES_STAGED="%{${GIT_RADAR_COLOR_CHANGES_STAGED:-$fg_bold[green]}%}" + COLOR_CHANGES_UNSTAGED="%{${GIT_RADAR_COLOR_CHANGES_UNSTAGED:-$fg_bold[red]}%}" + COLOR_CHANGES_CONFLICTED="%{${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-$fg_bold[yellow]}%}" + COLOR_CHANGES_UNTRACKED="%{${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-$fg_bold[white]}%}" - RESET_COLOR_LOCAL="${GIT_RADAR_COLOR_LOCAL_RESET:-$reset_color}" - RESET_COLOR_REMOTE="${GIT_RADAR_COLOR_REMOTE_RESET:-$reset_color}" - RESET_COLOR_CHANGES="${GIT_RADAR_COLOR_CHANGES_RESET:-$reset_color}" + RESET_COLOR_LOCAL="%{${GIT_RADAR_COLOR_LOCAL_RESET:-$reset_color}%}" + RESET_COLOR_REMOTE="%{${GIT_RADAR_COLOR_REMOTE_RESET:-$reset_color}%}" + RESET_COLOR_CHANGES="%{${GIT_RADAR_COLOR_CHANGES_RESET:-$reset_color}%}" } in_current_dir() { @@ -367,11 +367,11 @@ zsh_color_changes_status() { local changes="" if [[ -n "$porcelain" ]]; then - local staged_prefix="%{$COLOR_CHANGES_STAGED%}" - local unstaged_prefix="%{$COLOR_CHANGES_UNSTAGED%}" - local conflicted_prefix="%{$COLOR_CHANGES_CONFLICTED%}" - local untracked_prefix="%{$COLOR_CHANGES_UNTRACKED%}" - local suffix="%{$RESET_COLOR_CHANGES%}" + local staged_prefix="$COLOR_CHANGES_STAGED" + local unstaged_prefix="$COLOR_CHANGES_UNSTAGED" + local conflicted_prefix="$COLOR_CHANGES_CONFLICTED" + local untracked_prefix="$COLOR_CHANGES_UNTRACKED" + local suffix="$RESET_COLOR_CHANGES" local staged_changes="$(staged_status "$porcelain" "$staged_prefix" "$suffix")" local unstaged_changes="$(unstaged_status "$porcelain" "$unstaged_prefix" "$suffix")" @@ -424,9 +424,9 @@ bash_color_local_commits() { zsh_color_local_commits() { local separator="${1:- }" - local ahead_arrow="%{$COLOR_LOCAL_AHEAD%}↑%{$RESET_COLOR_LOCAL%}" - local behind_arrow="%{$COLOR_LOCAL_BEHIND%}↓%{$RESET_COLOR_LOCAL%}" - local diverged_arrow="%{$COLOR_LOCAL_DIVERGED%}⇵%{$RESET_COLOR_LOCAL%}" + local ahead_arrow="$COLOR_LOCAL_AHEAD↑$RESET_COLOR_LOCAL" + local behind_arrow="$COLOR_LOCAL_BEHIND↓$RESET_COLOR_LOCAL" + local diverged_arrow="$COLOR_LOCAL_DIVERGED⇵$RESET_COLOR_LOCAL" local local_commits="" if remote_branch="$(remote_branch_name)"; then @@ -471,10 +471,10 @@ bash_color_remote_commits() { zsh_color_remote_commits() { local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master - local green_ahead_arrow="%{$COLOR_REMOTE_AHEAD%}←%{$RESET_COLOR_REMOTE%}" - local red_behind_arrow="%{$COLOR_REMOTE_BEHIND%}→%{$RESET_COLOR_REMOTE%}" - local yellow_diverged_arrow="%{$COLOR_REMOTE_DIVERGED%}⇄%{$RESET_COLOR_REMOTE%}" - local not_upstream="%{$COLOR_REMOTE_NOT_UPSTREAM%}⚡%{$RESET_COLOR_REMOTE%}" + local green_ahead_arrow="$COLOR_REMOTE_AHEAD←$RESET_COLOR_REMOTE" + local red_behind_arrow="$COLOR_REMOTE_BEHIND→$RESET_COLOR_REMOTE" + local yellow_diverged_arrow="$COLOR_REMOTE_DIVERGED⇄$RESET_COLOR_REMOTE" + local not_upstream="$COLOR_REMOTE_NOT_UPSTREAM⚡$RESET_COLOR_REMOTE" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From 18a19fc516400f2f8db8925b599b70037ac04403 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 14:58:52 +0100 Subject: Duplicate Zsh color config for bash --- radar-base.sh | 62 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 8951b43..cb1d4b6 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -4,6 +4,26 @@ dot_git="" cwd="" remote="" +prepare_bash_colors() { + COLOR_REMOTE_AHEAD="\x01${GIT_RADAR_COLOR_REMOTE_AHEAD:-"\\033[1;32m"}\x02" + COLOR_REMOTE_BEHIND="\x01${GIT_RADAR_COLOR_REMOTE_BEHIND:-"\\033[1;31m"}\x02" + COLOR_REMOTE_DIVERGED="\x01${GIT_RADAR_COLOR_REMOTE_DIVERGED:-"\\033[1;33m"}\x02" + COLOR_REMOTE_NOT_UPSTREAM="\x01${GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM:-"\\033[1;31m"}\x02" + + COLOR_LOCAL_AHEAD="\x01${GIT_RADAR_COLOR_LOCAL_AHEAD:-"\\033[1;32m"}\x02" + COLOR_LOCAL_BEHIND="\x01${GIT_RADAR_COLOR_LOCAL_BEHIND:-"\\033[1;31m"}\x02" + COLOR_LOCAL_DIVERGED="\x01${GIT_RADAR_COLOR_LOCAL_DIVERGED:-"\\033[1;33m"}\x02" + + COLOR_CHANGES_STAGED="\x01${GIT_RADAR_COLOR_CHANGES_STAGED:-"\\033[1;32m"}\x02" + COLOR_CHANGES_UNSTAGED="\x01${GIT_RADAR_COLOR_CHANGES_UNSTAGED:-"\\033[1;31m"}\x02" + COLOR_CHANGES_CONFLICTED="\x01${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-"\\033[1;33m"}\x02" + COLOR_CHANGES_UNTRACKED="\x01${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-"\\033[1;37m"}\x02" + + RESET_COLOR_LOCAL="\x01${GIT_RADAR_COLOR_LOCAL_RESET:-"\\033[0m"}\x02" + RESET_COLOR_REMOTE="\x01${GIT_RADAR_COLOR_REMOTE_RESET:-"\\033[0m"}\x02" + RESET_COLOR_CHANGES="\x01${GIT_RADAR_COLOR_CHANGES_RESET:-"\\033[0m"}\x02" +} + prepare_zsh_colors() { autoload colors && colors @@ -329,16 +349,10 @@ bash_color_changes_status() { local changes="" if [[ -n "$porcelain" ]]; then - local green_staged_prefix="\x01\033[1;32m\x02" - local red_unstaged_prefix="\x01\033[1;31m\x02" - local yellow_conflicted_prefix="\x01\033[1;33m\x02" - local grey_untracked_prefix="\x01\033[1;37m\x02" - local reset_suffix="\x01\033[0m\x02" - - local staged_changes="$(staged_status "$porcelain" "$green_staged_prefix" "$reset_suffix")" - local unstaged_changes="$(unstaged_status "$porcelain" "$red_unstaged_prefix" "$reset_suffix")" - local untracked_changes="$(untracked_status "$porcelain" "$grey_untracked_prefix" "$reset_suffix")" - local conflicted_changes="$(conflicted_status "$porcelain" "$yellow_conflicted_prefix" "$reset_suffix")" + local staged_changes="$(staged_status "$porcelain" "$COLOR_CHANGES_STAGED" "$RESET_COLOR_CHANGES")" + local unstaged_changes="$(unstaged_status "$porcelain" "$COLOR_CHANGES_UNSTAGED" "$RESET_COLOR_CHANGES")" + local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" + local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" if [[ -n "$staged_changes" ]]; then staged_changes="$separator$staged_changes" fi @@ -367,16 +381,10 @@ zsh_color_changes_status() { local changes="" if [[ -n "$porcelain" ]]; then - local staged_prefix="$COLOR_CHANGES_STAGED" - local unstaged_prefix="$COLOR_CHANGES_UNSTAGED" - local conflicted_prefix="$COLOR_CHANGES_CONFLICTED" - local untracked_prefix="$COLOR_CHANGES_UNTRACKED" - local suffix="$RESET_COLOR_CHANGES" - - local staged_changes="$(staged_status "$porcelain" "$staged_prefix" "$suffix")" - local unstaged_changes="$(unstaged_status "$porcelain" "$unstaged_prefix" "$suffix")" - local untracked_changes="$(untracked_status "$porcelain" "$untracked_prefix" "$suffix")" - local conflicted_changes="$(conflicted_status "$porcelain" "$conflicted_prefix" "$suffix")" + local staged_changes="$(staged_status "$porcelain" "$COLOR_CHANGES_STAGED" "$RESET_COLOR_CHANGES")" + local unstaged_changes="$(unstaged_status "$porcelain" "$COLOR_CHANGES_UNSTAGED" "$RESET_COLOR_CHANGES")" + local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" + local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" if [[ -n "$staged_changes" ]]; then staged_changes="$separator$staged_changes" fi @@ -401,9 +409,9 @@ zsh_color_changes_status() { bash_color_local_commits() { local separator="${1:- }" - local green_ahead_arrow="\x01\033[1;32m\x02↑\x01\033[0m\x02" - local red_behind_arrow="\x01\033[1;31m\x02↓\x01\033[0m\x02" - local yellow_diverged_arrow="\x01\033[1;33m\x02⇵\x01\033[0m\x02" + local green_ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" + local red_behind_arrow="${COLOR_LOCAL_BEHIND}↓$RESET_COLOR_LOCAL" + local yellow_diverged_arrow="${COLOR_LOCAL_DIVERGED}⇵$RESET_COLOR_LOCAL" local local_commits="" if remote_branch="$(remote_branch_name)"; then @@ -446,10 +454,10 @@ zsh_color_local_commits() { bash_color_remote_commits() { local remote_master="\xF0\x9D\x98\xAE" # an italic m to represent master - local green_ahead_arrow="\x01\033[1;32m\x02←\x01\033[0m\x02" - local red_behind_arrow="\x01\033[1;31m\x02→\x01\033[0m\x02" - local yellow_diverged_arrow="\x01\033[1;33m\x02⇄\x01\033[0m\x02" - local not_upstream="\x01\033[1;31m\x02⚡\x01\033[0m\x02" + local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" + local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" + local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" + local not_upstream="${COLOR_REMOTE_NOT_UPSTREAM}⚡$RESET_COLOR_REMOTE" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From 5b5c784e6caf83652d92532f426f3f8d40836b21 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 16:36:48 +0100 Subject: Fix mistaken colour assignment --- radar-base.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index cb1d4b6..700ec22 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -351,8 +351,8 @@ bash_color_changes_status() { if [[ -n "$porcelain" ]]; then local staged_changes="$(staged_status "$porcelain" "$COLOR_CHANGES_STAGED" "$RESET_COLOR_CHANGES")" local unstaged_changes="$(unstaged_status "$porcelain" "$COLOR_CHANGES_UNSTAGED" "$RESET_COLOR_CHANGES")" - local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" - local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" + local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" + local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" if [[ -n "$staged_changes" ]]; then staged_changes="$separator$staged_changes" fi @@ -383,8 +383,8 @@ zsh_color_changes_status() { if [[ -n "$porcelain" ]]; then local staged_changes="$(staged_status "$porcelain" "$COLOR_CHANGES_STAGED" "$RESET_COLOR_CHANGES")" local unstaged_changes="$(unstaged_status "$porcelain" "$COLOR_CHANGES_UNSTAGED" "$RESET_COLOR_CHANGES")" - local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" - local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" + local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" + local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" if [[ -n "$staged_changes" ]]; then staged_changes="$separator$staged_changes" fi -- cgit v1.2.3 From 0a471db63edcb0ba1fcfb6792e51b791de3fcb81 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 16:46:28 +0100 Subject: Move autoload back to prompt.zsh to make testing easier --- radar-base.sh | 2 -- 1 file changed, 2 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 700ec22..b2ecd38 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -25,8 +25,6 @@ prepare_bash_colors() { } prepare_zsh_colors() { - autoload colors && colors - COLOR_REMOTE_AHEAD="%{${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}%}" COLOR_REMOTE_BEHIND="%{${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}%}" COLOR_REMOTE_DIVERGED="%{${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}%}" -- cgit v1.2.3 From c2dbe6f579bac9b40482970287e6a58783994257 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:22:13 +0100 Subject: Test zsh local commit colors --- radar-base.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index b2ecd38..63a18c9 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -430,9 +430,9 @@ bash_color_local_commits() { zsh_color_local_commits() { local separator="${1:- }" - local ahead_arrow="$COLOR_LOCAL_AHEAD↑$RESET_COLOR_LOCAL" - local behind_arrow="$COLOR_LOCAL_BEHIND↓$RESET_COLOR_LOCAL" - local diverged_arrow="$COLOR_LOCAL_DIVERGED⇵$RESET_COLOR_LOCAL" + local ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" + local behind_arrow="${COLOR_LOCAL_BEHIND}↓$RESET_COLOR_LOCAL" + local diverged_arrow="${COLOR_LOCAL_DIVERGED}⇵$RESET_COLOR_LOCAL" local local_commits="" if remote_branch="$(remote_branch_name)"; then -- cgit v1.2.3 From e388db84ee99641a0260767ccdd4c889b7ca4f7d Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sun, 30 Aug 2015 19:22:50 +0100 Subject: Test zsh remote commit colors --- radar-base.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 63a18c9..541b5e7 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -477,10 +477,10 @@ bash_color_remote_commits() { zsh_color_remote_commits() { local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master - local green_ahead_arrow="$COLOR_REMOTE_AHEAD←$RESET_COLOR_REMOTE" - local red_behind_arrow="$COLOR_REMOTE_BEHIND→$RESET_COLOR_REMOTE" - local yellow_diverged_arrow="$COLOR_REMOTE_DIVERGED⇄$RESET_COLOR_REMOTE" - local not_upstream="$COLOR_REMOTE_NOT_UPSTREAM⚡$RESET_COLOR_REMOTE" + local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" + local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" + local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" + local not_upstream="${COLOR_REMOTE_NOT_UPSTREAM}⚡$RESET_COLOR_REMOTE" if remote_branch="$(remote_branch_name)"; then remote_ahead="$(remote_ahead_of_master "$remote_branch")" -- cgit v1.2.3 From 3c500ca9fe517710d75d6d09084fa7038dea39db Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Mon, 31 Aug 2015 00:46:29 +0100 Subject: Provide a way to set a .gitradarrc file --- radar-base.sh | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 541b5e7..f707587 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -3,8 +3,13 @@ NO_REMOTE_STATUS='--no-remote-status' dot_git="" cwd="" remote="" +rcfile_path="$HOME" prepare_bash_colors() { + if [ -f "$rcfile_path/.gitradarrc" ]; then + source "$rcfile_path/.gitradarrc" + fi + COLOR_REMOTE_AHEAD="\x01${GIT_RADAR_COLOR_REMOTE_AHEAD:-"\\033[1;32m"}\x02" COLOR_REMOTE_BEHIND="\x01${GIT_RADAR_COLOR_REMOTE_BEHIND:-"\\033[1;31m"}\x02" COLOR_REMOTE_DIVERGED="\x01${GIT_RADAR_COLOR_REMOTE_DIVERGED:-"\\033[1;33m"}\x02" @@ -25,6 +30,10 @@ prepare_bash_colors() { } prepare_zsh_colors() { + if [ -f "$rcfile_path/.gitradarrc" ]; then + source "$rcfile_path/.gitradarrc" + fi + COLOR_REMOTE_AHEAD="%{${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}%}" COLOR_REMOTE_BEHIND="%{${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}%}" COLOR_REMOTE_DIVERGED="%{${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}%}" -- cgit v1.2.3 From 1342bd1e5fbef270db72f302bd6c380a7fec29ac Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Tue, 1 Sep 2015 13:40:03 +0100 Subject: Make branch color and master symbol configurable --- radar-base.sh | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index f707587..5672e07 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -24,9 +24,13 @@ prepare_bash_colors() { COLOR_CHANGES_CONFLICTED="\x01${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-"\\033[1;33m"}\x02" COLOR_CHANGES_UNTRACKED="\x01${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-"\\033[1;37m"}\x02" + COLOR_BRANCH="\x01${GIT_RADAR_COLOR_BRANCH:-"\\033[0m"}\x02" + MASTER_SYMBOL="${GIT_RADAR_MASTER_SYMBOL:-"\\x01\\033[0m\\x02\\xF0\\x9D\\x98\\xAE\\x01\\033[0m\\x02"}" + RESET_COLOR_LOCAL="\x01${GIT_RADAR_COLOR_LOCAL_RESET:-"\\033[0m"}\x02" RESET_COLOR_REMOTE="\x01${GIT_RADAR_COLOR_REMOTE_RESET:-"\\033[0m"}\x02" RESET_COLOR_CHANGES="\x01${GIT_RADAR_COLOR_CHANGES_RESET:-"\\033[0m"}\x02" + RESET_COLOR_BRANCH="\x01${GIT_RADAR_COLOR_BRANCH_RESET:-"\\033[0m"}\x02" } prepare_zsh_colors() { @@ -48,9 +52,15 @@ prepare_zsh_colors() { COLOR_CHANGES_CONFLICTED="%{${GIT_RADAR_COLOR_CHANGES_CONFLICTED:-$fg_bold[yellow]}%}" COLOR_CHANGES_UNTRACKED="%{${GIT_RADAR_COLOR_CHANGES_UNTRACKED:-$fg_bold[white]}%}" + local italic_m="$(printf '\xF0\x9D\x98\xAE')" + + COLOR_BRANCH="%{${GIT_RADAR_COLOR_BRANCH:-$reset_color}%}" + MASTER_SYMBOL="${GIT_RADAR_MASTER_SYMBOL:-"%{$reset_color%}$italic_m%{$reset_color%}"}" + RESET_COLOR_LOCAL="%{${GIT_RADAR_COLOR_LOCAL_RESET:-$reset_color}%}" RESET_COLOR_REMOTE="%{${GIT_RADAR_COLOR_REMOTE_RESET:-$reset_color}%}" RESET_COLOR_CHANGES="%{${GIT_RADAR_COLOR_CHANGES_RESET:-$reset_color}%}" + RESET_COLOR_BRANCH="%{${GIT_RADAR_COLOR_BRANCH_RESET:-$reset_color}%}" } in_current_dir() { @@ -168,7 +178,7 @@ branch_ref() { readable_branch_name() { if is_repo; then - printf '%s' "$(branch_name || printf '%s' "detached@$(commit_short_sha)")" + printf '%s' "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" fi } @@ -460,7 +470,6 @@ zsh_color_local_commits() { } bash_color_remote_commits() { - local remote_master="\xF0\x9D\x98\xAE" # an italic m to represent master local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" @@ -471,11 +480,11 @@ bash_color_remote_commits() { remote_behind="$(remote_behind_of_master "$remote_branch")" if [[ "$remote_behind" -gt "0" && "$remote_ahead" -gt "0" ]]; then - remote="$remote_master $remote_behind $yellow_diverged_arrow $remote_ahead " + remote="$MASTER_SYMBOL $remote_behind $yellow_diverged_arrow $remote_ahead " elif [[ "$remote_ahead" -gt "0" ]]; then - remote="$remote_master $green_ahead_arrow $remote_ahead " + remote="$MASTER_SYMBOL $green_ahead_arrow $remote_ahead " elif [[ "$remote_behind" -gt "0" ]]; then - remote="$remote_master $remote_behind $red_behind_arrow " + remote="$MASTER_SYMBOL $remote_behind $red_behind_arrow " fi else remote="upstream $not_upstream " @@ -485,7 +494,6 @@ bash_color_remote_commits() { } zsh_color_remote_commits() { - local remote_master="$(printf '\xF0\x9D\x98\xAE')" # an italic m to represent master local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" @@ -496,11 +504,11 @@ zsh_color_remote_commits() { remote_behind="$(remote_behind_of_master "$remote_branch")" if [[ "$remote_behind" -gt "0" && "$remote_ahead" -gt "0" ]]; then - remote="$remote_master $remote_behind $yellow_diverged_arrow $remote_ahead " + remote="$MASTER_SYMBOL $remote_behind $yellow_diverged_arrow $remote_ahead " elif [[ "$remote_ahead" -gt "0" ]]; then - remote="$remote_master $green_ahead_arrow $remote_ahead " + remote="$MASTER_SYMBOL $green_ahead_arrow $remote_ahead " elif [[ "$remote_behind" -gt "0" ]]; then - remote="$remote_master $remote_behind $red_behind_arrow " + remote="$MASTER_SYMBOL $remote_behind $red_behind_arrow " fi else remote="upstream $not_upstream " -- cgit v1.2.3 From 393013fba5bc7ec3402de4c1b2faf47dd7493c59 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 2 Sep 2015 17:42:17 +0100 Subject: Allow for shell specific rc files --- radar-base.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 5672e07..25a4113 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -6,7 +6,9 @@ remote="" rcfile_path="$HOME" prepare_bash_colors() { - if [ -f "$rcfile_path/.gitradarrc" ]; then + if [ -f "$rcfile_path/.gitradarrc.bash" ]; then + source "$rcfile_path/.gitradarrc.bash" + elif [ -f "$rcfile_path/.gitradarrc" ]; then source "$rcfile_path/.gitradarrc" fi @@ -34,7 +36,9 @@ prepare_bash_colors() { } prepare_zsh_colors() { - if [ -f "$rcfile_path/.gitradarrc" ]; then + if [ -f "$rcfile_path/.gitradarrc.zsh" ]; then + source "$rcfile_path/.gitradarrc.zsh" + elif [ -f "$rcfile_path/.gitradarrc" ]; then source "$rcfile_path/.gitradarrc" fi -- cgit v1.2.3 From f2f8fe92cea4ab6ab8a82cdf4863b1dc6e6e2471 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sat, 5 Sep 2015 10:33:28 +0100 Subject: Fix mistaken colour output on bash --- radar-base.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 25a4113..c793eab 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -182,7 +182,7 @@ branch_ref() { readable_branch_name() { if is_repo; then - printf '%s' "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" + printf "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" fi } -- cgit v1.2.3 From 3884b1fdf423f4e8655dd47bef0ccb2ebdd68c6d Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Sat, 5 Sep 2015 10:50:47 +0100 Subject: Fix colour issue for zsh --- radar-base.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index c793eab..2ad9ce7 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -180,7 +180,13 @@ branch_ref() { fi } -readable_branch_name() { +zsh_readable_branch_name() { + if is_repo; then + printf '%s' "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" + fi +} + +bash_readable_branch_name() { if is_repo; then printf "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" fi -- cgit v1.2.3 From 9cfc2ed7f46fa9dea9fbeeef51a8ea8883c41c59 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 16 Sep 2015 14:21:43 +0100 Subject: Merge bash and zsh specific render functions --- radar-base.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 2ad9ce7..12cab90 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -12,6 +12,8 @@ prepare_bash_colors() { source "$rcfile_path/.gitradarrc" fi + PRINT_F_OPTION="" + COLOR_REMOTE_AHEAD="\x01${GIT_RADAR_COLOR_REMOTE_AHEAD:-"\\033[1;32m"}\x02" COLOR_REMOTE_BEHIND="\x01${GIT_RADAR_COLOR_REMOTE_BEHIND:-"\\033[1;31m"}\x02" COLOR_REMOTE_DIVERGED="\x01${GIT_RADAR_COLOR_REMOTE_DIVERGED:-"\\033[1;33m"}\x02" @@ -42,6 +44,8 @@ prepare_zsh_colors() { source "$rcfile_path/.gitradarrc" fi + PRINT_F_OPTION="%s" + COLOR_REMOTE_AHEAD="%{${GIT_RADAR_COLOR_REMOTE_AHEAD:-$fg_bold[green]}%}" COLOR_REMOTE_BEHIND="%{${GIT_RADAR_COLOR_REMOTE_BEHIND:-$fg_bold[red]}%}" COLOR_REMOTE_DIVERGED="%{${GIT_RADAR_COLOR_REMOTE_DIVERGED:-$fg_bold[yellow]}%}" @@ -398,7 +402,7 @@ bash_color_changes_status() { changes="$staged_changes$conflicted_changes$unstaged_changes$untracked_changes" fi - printf "$changes" + printf $PRINT_F_OPTION "$changes" } zsh_color_changes_status() { @@ -430,7 +434,7 @@ zsh_color_changes_status() { changes="$staged_changes$conflicted_changes$unstaged_changes$untracked_changes" fi - printf %s "$changes" + printf $PRINT_F_OPTION "$changes" } bash_color_local_commits() { @@ -453,7 +457,7 @@ bash_color_local_commits() { local_commits="$separator$local_ahead$green_ahead_arrow" fi fi - printf "$local_commits" + printf $PRINT_F_OPTION "$local_commits" } zsh_color_local_commits() { @@ -476,7 +480,7 @@ zsh_color_local_commits() { local_commits="$separator$local_ahead$ahead_arrow" fi fi - printf %s "$local_commits" + printf $PRINT_F_OPTION "$local_commits" } bash_color_remote_commits() { @@ -500,7 +504,7 @@ bash_color_remote_commits() { remote="upstream $not_upstream " fi - printf "$remote" + printf $PRINT_F_OPTION "$remote" } zsh_color_remote_commits() { @@ -524,7 +528,7 @@ zsh_color_remote_commits() { remote="upstream $not_upstream " fi - printf %s "$remote" + printf $PRINT_F_OPTION "$remote" } show_remote_status() { if [[ $@ == *$NO_REMOTE_STATUS* ]]; then -- cgit v1.2.3 From 1285baa3c095962265dc07b515ac9c0f7e75b959 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 16 Sep 2015 14:24:29 +0100 Subject: Merge zsh and bash remote commit diff --- radar-base.sh | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 12cab90..747cb5e 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -483,7 +483,7 @@ zsh_color_local_commits() { printf $PRINT_F_OPTION "$local_commits" } -bash_color_remote_commits() { +color_remote_commits() { local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" @@ -507,29 +507,14 @@ bash_color_remote_commits() { printf $PRINT_F_OPTION "$remote" } -zsh_color_remote_commits() { - local green_ahead_arrow="${COLOR_REMOTE_AHEAD}←$RESET_COLOR_REMOTE" - local red_behind_arrow="${COLOR_REMOTE_BEHIND}→$RESET_COLOR_REMOTE" - local yellow_diverged_arrow="${COLOR_REMOTE_DIVERGED}⇄$RESET_COLOR_REMOTE" - local not_upstream="${COLOR_REMOTE_NOT_UPSTREAM}⚡$RESET_COLOR_REMOTE" - - if remote_branch="$(remote_branch_name)"; then - remote_ahead="$(remote_ahead_of_master "$remote_branch")" - remote_behind="$(remote_behind_of_master "$remote_branch")" - - if [[ "$remote_behind" -gt "0" && "$remote_ahead" -gt "0" ]]; then - remote="$MASTER_SYMBOL $remote_behind $yellow_diverged_arrow $remote_ahead " - elif [[ "$remote_ahead" -gt "0" ]]; then - remote="$MASTER_SYMBOL $green_ahead_arrow $remote_ahead " - elif [[ "$remote_behind" -gt "0" ]]; then - remote="$MASTER_SYMBOL $remote_behind $red_behind_arrow " - fi - else - remote="upstream $not_upstream " - fi +bash_color_remote_commits() { + color_remote_commits +} - printf $PRINT_F_OPTION "$remote" +zsh_color_remote_commits() { + color_remote_commits } + show_remote_status() { if [[ $@ == *$NO_REMOTE_STATUS* ]]; then return 1 # don't show the git remote status -- cgit v1.2.3 From d4ce9372c1f5ee82ac019d5a3c84f8af64cb0e4f Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 16 Sep 2015 14:26:27 +0100 Subject: Merge zsh and bash local commit render func --- radar-base.sh | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index 747cb5e..fb5fa90 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -437,7 +437,7 @@ zsh_color_changes_status() { printf $PRINT_F_OPTION "$changes" } -bash_color_local_commits() { +color_local_commits() { local separator="${1:- }" local green_ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" @@ -460,27 +460,12 @@ bash_color_local_commits() { printf $PRINT_F_OPTION "$local_commits" } -zsh_color_local_commits() { - local separator="${1:- }" - - local ahead_arrow="${COLOR_LOCAL_AHEAD}↑$RESET_COLOR_LOCAL" - local behind_arrow="${COLOR_LOCAL_BEHIND}↓$RESET_COLOR_LOCAL" - local diverged_arrow="${COLOR_LOCAL_DIVERGED}⇵$RESET_COLOR_LOCAL" - - local local_commits="" - if remote_branch="$(remote_branch_name)"; then - local_ahead="$(commits_ahead_of_remote "$remote_branch")" - local_behind="$(commits_behind_of_remote "$remote_branch")" +bash_color_local_commits() { + color_local_commits +} - if [[ "$local_behind" -gt "0" && "$local_ahead" -gt "0" ]]; then - local_commits="$separator$local_behind$diverged_arrow$local_ahead" - elif [[ "$local_behind" -gt "0" ]]; then - local_commits="$separator$local_behind$behind_arrow" - elif [[ "$local_ahead" -gt "0" ]]; then - local_commits="$separator$local_ahead$ahead_arrow" - fi - fi - printf $PRINT_F_OPTION "$local_commits" +zsh_color_local_commits() { + color_local_commits } color_remote_commits() { -- cgit v1.2.3 From 223312b3ce46caaabb233d03722d6393e9631706 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 16 Sep 2015 14:28:19 +0100 Subject: Merge the zsh/bash changes render function --- radar-base.sh | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index fb5fa90..a4c67a1 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -373,7 +373,7 @@ untracked_status() { printf '%s' "$untracked_string" } -bash_color_changes_status() { +color_changes_status() { local separator="${1:- }" local porcelain="$(porcelain_status)" @@ -405,36 +405,12 @@ bash_color_changes_status() { printf $PRINT_F_OPTION "$changes" } -zsh_color_changes_status() { - local separator="${1:- }" - - local porcelain="$(porcelain_status)" - local changes="" - - if [[ -n "$porcelain" ]]; then - local staged_changes="$(staged_status "$porcelain" "$COLOR_CHANGES_STAGED" "$RESET_COLOR_CHANGES")" - local unstaged_changes="$(unstaged_status "$porcelain" "$COLOR_CHANGES_UNSTAGED" "$RESET_COLOR_CHANGES")" - local untracked_changes="$(untracked_status "$porcelain" "$COLOR_CHANGES_UNTRACKED" "$RESET_COLOR_CHANGES")" - local conflicted_changes="$(conflicted_status "$porcelain" "$COLOR_CHANGES_CONFLICTED" "$RESET_COLOR_CHANGES")" - if [[ -n "$staged_changes" ]]; then - staged_changes="$separator$staged_changes" - fi - - if [[ -n "$unstaged_changes" ]]; then - unstaged_changes="$separator$unstaged_changes" - fi - - if [[ -n "$conflicted_changes" ]]; then - conflicted_changes="$separator$conflicted_changes" - fi - - if [[ -n "$untracked_changes" ]]; then - untracked_changes="$separator$untracked_changes" - fi +bash_color_changes_status() { + color_changes_status +} - changes="$staged_changes$conflicted_changes$unstaged_changes$untracked_changes" - fi - printf $PRINT_F_OPTION "$changes" +zsh_color_changes_status() { + color_changes_status } color_local_commits() { -- cgit v1.2.3 From 2c0be1e2fd311a5fd18726b44be1a0ff8ae823e4 Mon Sep 17 00:00:00 2001 From: Michael Allen Date: Wed, 16 Sep 2015 14:31:23 +0100 Subject: Merge the zsh/bash readable branch function --- radar-base.sh | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'radar-base.sh') diff --git a/radar-base.sh b/radar-base.sh index a4c67a1..d9cd8f5 100755 --- a/radar-base.sh +++ b/radar-base.sh @@ -184,18 +184,6 @@ branch_ref() { fi } -zsh_readable_branch_name() { - if is_repo; then - printf '%s' "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" - fi -} - -bash_readable_branch_name() { - if is_repo; then - printf "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" - fi -} - remote_branch_name() { local localRef="\/$(branch_name)$" if [[ -n "$localRef" ]]; then @@ -476,6 +464,20 @@ zsh_color_remote_commits() { color_remote_commits } +readable_branch_name() { + if is_repo; then + printf $PRINT_F_OPTION "$COLOR_BRANCH$(branch_name || printf '%s' "detached@$(commit_short_sha)")$RESET_COLOR_BRANCH" + fi +} + +zsh_readable_branch_name() { + readable_branch_name +} + +bash_readable_branch_name() { + readable_branch_name +} + show_remote_status() { if [[ $@ == *$NO_REMOTE_STATUS* ]]; then return 1 # don't show the git remote status -- cgit v1.2.3