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 ++++++-- test-colors.sh | 46 +++++++++++++++++++++++----------------------- 2 files changed, 29 insertions(+), 25 deletions(-) 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 diff --git a/test-colors.sh b/test-colors.sh index 196b60b..59a8704 100755 --- a/test-colors.sh +++ b/test-colors.sh @@ -118,27 +118,27 @@ reset_env_vars() { } create_rc_file() { - echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc - - echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc - echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc - - echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc - echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc + echo 'GIT_RADAR_COLOR_REMOTE_AHEAD="remote-ahead"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_BEHIND="remote-behind"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_DIVERGED="remote-diverged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_NOT_UPSTREAM="not-upstream"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_LOCAL_AHEAD="local-ahead"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_LOCAL_BEHIND="local-behind"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_LOCAL_DIVERGED="local-diverged"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_CHANGES_STAGED="changes-staged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_UNSTAGED="changes-unstaged"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_CONFLICTED="changes-conflicted"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_UNTRACKED="changes-untracked"' >> .gitradarrc$1 + + echo 'export GIT_RADAR_COLOR_BRANCH="branch-color"' >> .gitradarrc$1 + echo 'export GIT_RADAR_MASTER_SYMBOL="m"' >> .gitradarrc$1 + + echo 'GIT_RADAR_COLOR_LOCAL_RESET="local-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_REMOTE_RESET="remote-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_CHANGES_RESET="change-reset"' >> .gitradarrc$1 + echo 'GIT_RADAR_COLOR_BRANCH_RESET="branch-reset"' >> .gitradarrc$1 } test_with_rcfile_bash() { @@ -147,7 +147,7 @@ test_with_rcfile_bash() { rcfile_path="$(pwd)" - create_rc_file + create_rc_file ".bash" prepare_bash_colors assertEquals "$COLOR_REMOTE_AHEAD" "\x01remote-ahead\x02" @@ -181,7 +181,7 @@ test_with_rcfile_zsh() { rcfile_path="$(pwd)" - create_rc_file + create_rc_file ".zsh" mock_zsh_colors prepare_zsh_colors -- cgit v1.2.3