summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xprompt.bash1
-rwxr-xr-xradar-base.sh62
2 files changed, 36 insertions, 27 deletions
diff --git a/prompt.bash b/prompt.bash
index 429c88d..604d8e1 100755
--- a/prompt.bash
+++ b/prompt.bash
@@ -5,6 +5,7 @@ args=$@
source "$dot/radar-base.sh"
if is_repo; then
+ prepare_bash_colors
printf " \x01\033[1;30m\x02git:(\x01\033[0m\x02"
if show_remote_status $args; then
bash_color_remote_commits
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")"