From b745d72722490e47a2aa23b644c26cfae456d4b2 Mon Sep 17 00:00:00 2001 From: Martin Gondermann Date: Thu, 9 Oct 2014 21:51:31 +0200 Subject: [PATCH] Optimized themes --- gitprompt.sh | 32 +++++-- gitstatus.sh | 2 +- themes/Custom.bgptemplate | 53 +++++++++++ themes/Default.bgptheme | 94 ++++++++++++++------ themes/Default_NoExitState.bgptheme | 46 +--------- themes/Default_NoExitState_Ubuntu.bgptheme | 42 +-------- themes/Default_Ubuntu.bgptheme | 45 +--------- themes/Solarized.bgptheme | 50 ++--------- themes/Solarized_NoExitState.bgptheme | 49 ++-------- themes/Solarized_NoExitState_Ubuntu.bgptheme | 51 ++--------- themes/Solarized_Ubuntu.bgptheme | 52 ++--------- 11 files changed, 186 insertions(+), 330 deletions(-) create mode 100644 themes/Custom.bgptemplate diff --git a/gitprompt.sh b/gitprompt.sh index 1c18ce3..1e3e691 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -9,7 +9,7 @@ function async_run() function git_prompt_dir() { - # assume the gitstatus.py is in the same directory as this script + # assume the gitstatus.sh is in the same directory as this script # code thanks to http://stackoverflow.com/questions/59895 if [ -z "$__GIT_PROMPT_DIR" ]; then local SOURCE="${BASH_SOURCE[0]}" @@ -67,6 +67,14 @@ function get_theme() fi } +function git_prompt_load_theme() +{ + get_theme + local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" + source "${DEFAULT_THEME_FILE}" + source "${__GIT_PROMPT_THEME_FILE}" +} + function git_prompt_list_themes() { local oldTheme @@ -111,7 +119,11 @@ function git_prompt_make_custom_theme() { else echoc ${Green} "Creating new cutom theme in \"${HOME}/.git-prompt-colors.sh\"" echoc ${DimYellow} "Please add ${Magenta}\"GIT_PROMPT_THEME=Custom\"${DimYellow} to your .bashrc to use this theme" - cp "${__GIT_PROMPT_DIR}/themes/${base}.bgptheme" "${HOME}/.git-prompt-colors.sh" + if [[ "${base}" == "Default" ]]; then + cp "${__GIT_PROMPT_DIR}/themes/Custom.bgptemplate" "${HOME}/.git-prompt-colors.sh" + else + cp "${__GIT_PROMPT_DIR}/themes/${base}.bgptheme" "${HOME}/.git-prompt-colors.sh" + fi fi fi } @@ -168,7 +180,7 @@ function gp_maybe_set_envar_to_path(){ git_prompt_reset() { local var - for var in GIT_PROMPT_DIR __GIT_PROMPT_COLORS_FILE __PROMPT_COLORS_FILE __GIT_STATUS_CMD ; do + for var in GIT_PROMPT_DIR __GIT_PROMPT_COLORS_FILE __PROMPT_COLORS_FILE __GIT_STATUS_CMD GIT_PROMPT_THEME_NAME; do unset $var done } @@ -193,8 +205,7 @@ function git_prompt_config() # source the user's ~/.git-prompt-colors.sh file, or the one that should be # sitting in the same directory as this script - get_theme - source "$__GIT_PROMPT_THEME_FILE" + git_prompt_load_theme if [ $GIT_PROMPT_LAST_COMMAND_STATE = 0 ]; then LAST_COMMAND_INDICATOR="$GIT_PROMPT_COMMAND_OK"; @@ -257,8 +268,8 @@ function git_prompt_config() GIT_PROMPT_FETCH_TIMEOUT=${1-5} if [[ -z "$__GIT_STATUS_CMD" ]] ; then # if GIT_STATUS_CMD not defined.. git_prompt_dir - if ! gp_maybe_set_envar_to_path __GIT_STATUS_CMD "$__GIT_PROMPT_DIR/gitstatus.sh" "$__GIT_PROMPT_DIR/gitstatus.py" ; then - echo 1>&2 "Cannot find gitstatus.sh or gitstatus.py!" + if ! gp_maybe_set_envar_to_path __GIT_STATUS_CMD "$__GIT_PROMPT_DIR/gitstatus.sh" ; then + echo 1>&2 "Cannot find gitstatus.sh!" fi # __GIT_STATUS_CMD defined fi @@ -322,10 +333,15 @@ function checkUpstream() { function replaceSymbols() { + if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then + GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING=L + fi + local VALUE=${1/_AHEAD_/${GIT_PROMPT_SYMBOLS_AHEAD}} local VALUE1=${VALUE/_BEHIND_/${GIT_PROMPT_SYMBOLS_BEHIND}} + local VALUE2=${VALUE1/_NO_REMOTE_TRACKING_/${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING}} - echo ${VALUE1/_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}} + echo ${VALUE2/_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}} } function updatePrompt() { diff --git a/gitstatus.sh b/gitstatus.sh index 565c32b..601e4cf 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -102,7 +102,7 @@ if [[ -z "$remote" ]] ; then fi if [[ "$has_remote_tracking" == "0" ]] ; then - remote='L' + remote='_NO_REMOTE_TRACKING_' fi for w in "$branch" "$remote" $num_staged $num_conflicts $num_changed $num_untracked $num_stashed $clean ; do diff --git a/themes/Custom.bgptemplate b/themes/Custom.bgptemplate new file mode 100644 index 0000000..8305d70 --- /dev/null +++ b/themes/Custom.bgptemplate @@ -0,0 +1,53 @@ +# This is the custom theme template for gitprompt.sh + +# These are the defaults from the "Default" theme +# You just need to override what you want to have changed +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Custom" + + # Time12a="\$(date +%H:%M)" + # PathShort="\w"; + + ## These are the color definitions used by gitprompt.sh + # GIT_PROMPT_PREFIX="[" # start of the git info string + # GIT_PROMPT_SUFFIX="]" # the end of the git info string + # GIT_PROMPT_SEPARATOR="|" # separates each item + + # GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory + # GIT_PROMPT_STAGED="${Red}●" # the number of staged files/directories + # GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict + # GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files + + # GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind + # GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs + # GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir + # GIT_PROMPT_CLEAN="${BoldGreen}✔" # a colored flag indicating a "clean" repo + + ## For the command indicator, the placeholder _LAST_COMMAND_STATE_ + ## will be replaced with the exit code of the last command + ## e.g. + ## GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 + ## GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 + + # GIT_PROMPT_COMMAND_OK="${Green}✔" # indicator if the last command returned with an exit code of 0 + # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 + + ## template for displaying the current virtual environment + ## use the placeholder _VIRTUALENV_ will be replaced with + ## the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) + # GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " + + ## _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL + # GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}" + # GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}" + # GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ " + # GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # " + + ## Please do not add colors to these symbols + # GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" + # GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" + # GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found + # GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="L" # This symbol is written after the branch, if the branch is not tracked +} + +reload_git_prompt_colors "Custom" \ No newline at end of file diff --git a/themes/Default.bgptheme b/themes/Default.bgptheme index fbb56ab..d415eaf 100644 --- a/themes/Default.bgptheme +++ b/themes/Default.bgptheme @@ -1,23 +1,55 @@ # This is the default theme for gitprompt.sh -define_git_prompt_colors() { +unset_git_prompt_colors() { + unset Time12a + unset PathShort + unset GIT_PROMPT_PREFIX + unset GIT_PROMPT_SUFFIX + unset GIT_PROMPT_SEPARATOR + unset GIT_PROMPT_BRANCH + unset GIT_PROMPT_STAGED + unset GIT_PROMPT_CONFLICTS + unset GIT_PROMPT_CHANGED + unset GIT_PROMPT_REMOTE + unset GIT_PROMPT_UNTRACKED + unset GIT_PROMPT_STASHED + unset GIT_PROMPT_CLEAN + unset GIT_PROMPT_COMMAND_OK + unset GIT_PROMPT_COMMAND_FAIL + unset GIT_PROMPT_VIRTUALENV + unset GIT_PROMPT_START_USER + unset GIT_PROMPT_START_ROOT + unset GIT_PROMPT_END_USER + unset GIT_PROMPT_END_ROOT + unset GIT_PROMPT_SYMBOLS_AHEAD + unset GIT_PROMPT_SYMBOLS_BEHIND + unset GIT_PROMPT_SYMBOLS_PREHASH + unset GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING +} + +define_helpers() +{ Time12a="\$(date +%H:%M)" - PathShort="\w" + PathShort="\w"; +} + +define_undefined_git_prompt_colors() { + if [[ -z ${GIT_PROMPT_THEME_NAME} ]]; then GIT_PROMPT_THEME_NAME="Default"; fi # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item + if [[ -z ${GIT_PROMPT_PREFIX} ]]; then GIT_PROMPT_PREFIX="["; fi # start of the git info string + if [[ -z ${GIT_PROMPT_SUFFIX} ]]; then GIT_PROMPT_SUFFIX="]"; fi # the end of the git info string + if [[ -z ${GIT_PROMPT_SEPARATOR} ]]; then GIT_PROMPT_SEPARATOR="|"; fi # separates each item - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Red}●" # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files + if [[ -z ${GIT_PROMPT_BRANCH} ]]; then GIT_PROMPT_BRANCH="${Magenta}"; fi # the git branch that is active in the current directory + if [[ -z ${GIT_PROMPT_STAGED} ]]; then GIT_PROMPT_STAGED="${Red}●"; fi # the number of staged files/directories + if [[ -z ${GIT_PROMPT_CONFLICTS} ]]; then GIT_PROMPT_CONFLICTS="${Red}✖ "; fi # the number of files in conflict + if [[ -z ${GIT_PROMPT_CHANGED} ]]; then GIT_PROMPT_CHANGED="${Blue}✚ "; fi # the number of changed files - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${BoldGreen}✔" # a colored flag indicating a "clean" repo + if [[ -z ${GIT_PROMPT_REMOTE} ]]; then GIT_PROMPT_REMOTE=" "; fi # the remote branch name (if any) and the symbols for ahead and behind + if [[ -z ${GIT_PROMPT_UNTRACKED} ]]; then GIT_PROMPT_UNTRACKED="${Cyan}…"; fi # the number of untracked files/dirs + if [[ -z ${GIT_PROMPT_STASHED} ]]; then GIT_PROMPT_STASHED="${BoldBlue}⚑ "; fi # the number of stashed files/dir + if [[ -z ${GIT_PROMPT_CLEAN} ]]; then GIT_PROMPT_CLEAN="${BoldGreen}✔"; fi # a colored flag indicating a "clean" repo # For the command indicator, the placeholder _LAST_COMMAND_STATE_ # will be replaced with the exit code of the last command @@ -25,26 +57,38 @@ define_git_prompt_colors() { # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - GIT_PROMPT_COMMAND_OK="${Green}✔" # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 + if [[ -z ${GIT_PROMPT_COMMAND_OK} ]]; then GIT_PROMPT_COMMAND_OK="${Green}✔"; fi # indicator if the last command returned with an exit code of 0 + if [[ -z ${GIT_PROMPT_COMMAND_FAIL} ]]; then GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_"; fi # indicator if the last command returned with an exit code of other than 0 # template for displaying the current virtual environment # use the placeholder _VIRTUALENV_ will be replaced with # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " + if [[ -z ${GIT_PROMPT_VIRTUALENV} ]]; then GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) "; fi # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL - GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}" - GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}" - GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ " - GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # " + if [[ -z ${GIT_PROMPT_START_USER} ]]; then GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}"; fi + if [[ -z ${GIT_PROMPT_START_ROOT} ]]; then GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}"; fi + if [[ -z ${GIT_PROMPT_END_USER} ]]; then GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ "; fi + if [[ -z ${GIT_PROMPT_END_ROOT} ]]; then GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # "; fi # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found + if [[ -z ${GIT_PROMPT_SYMBOLS_AHEAD} ]]; then GIT_PROMPT_SYMBOLS_AHEAD="↑·"; fi # The symbol for "n versions ahead of origin" + if [[ -z ${GIT_PROMPT_SYMBOLS_BEHIND} ]]; then GIT_PROMPT_SYMBOLS_BEHIND="↓·"; fi # The symbol for "n versions behind of origin" + if [[ -z ${GIT_PROMPT_SYMBOLS_PREHASH} ]]; then GIT_PROMPT_SYMBOLS_PREHASH=":"; fi # Written before hash of commit, if no name could be found + if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING="L"; fi # This symbol is written after the branch, if the branch is not tracked +} + +# call only from theme file +reload_git_prompt_colors() { + if [[ "${GIT_PROMPT_THEME_NAME}" != $1 ]]; then + unset_git_prompt_colors + define_helpers + override_git_prompt_colors + define_undefined_git_prompt_colors + fi } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors +if [[ "${GIT_PROMPT_THEME}" == "Default" && "${GIT_PROMPT_THEME_NAME}" != "Default" ]]; then + define_helpers + define_undefined_git_prompt_colors fi diff --git a/themes/Default_NoExitState.bgptheme b/themes/Default_NoExitState.bgptheme index e238749..239aae1 100644 --- a/themes/Default_NoExitState.bgptheme +++ b/themes/Default_NoExitState.bgptheme @@ -1,51 +1,11 @@ # This is the default theme for gitprompt.sh # without the indicator of the last command state -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Red}●" # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${BoldGreen}✔" # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - - GIT_PROMPT_COMMAND_OK="${Green}✔" # indicator if the last command returned with an exit code of 0 +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Default NoExitState" GIT_PROMPT_COMMAND_FAIL="${Red}✘" # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL GIT_PROMPT_START_USER="${Yellow}${PathShort}${ResetColor}" GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}" - GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ " - GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Default NoExitState" diff --git a/themes/Default_NoExitState_Ubuntu.bgptheme b/themes/Default_NoExitState_Ubuntu.bgptheme index 1f7a1e7..2af22f3 100644 --- a/themes/Default_NoExitState_Ubuntu.bgptheme +++ b/themes/Default_NoExitState_Ubuntu.bgptheme @@ -2,51 +2,15 @@ # without the indicator of the last command state # tweaked for Ubuntu terminal fonts -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Default NoExitState Ubuntu" GIT_PROMPT_STAGED="${Red}● " # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind GIT_PROMPT_UNTRACKED="${Cyan}… " # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir GIT_PROMPT_CLEAN="${BoldGreen}✔ " # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - GIT_PROMPT_COMMAND_OK="${Green}✔ " # indicator if the last command returned with an exit code of 0 GIT_PROMPT_COMMAND_FAIL="${Red}✘ " # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL GIT_PROMPT_START_USER="${Yellow}${PathShort}${ResetColor}" GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}" - GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ " - GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Default NoExitState Ubuntu" \ No newline at end of file diff --git a/themes/Default_Ubuntu.bgptheme b/themes/Default_Ubuntu.bgptheme index a1b54b0..7ddf91f 100644 --- a/themes/Default_Ubuntu.bgptheme +++ b/themes/Default_Ubuntu.bgptheme @@ -1,51 +1,12 @@ # This is the default theme for gitprompt.sh # tweaked for Ubuntu terminal fonts -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Default Ubuntu" GIT_PROMPT_STAGED="${Red}● " # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind GIT_PROMPT_UNTRACKED="${Cyan}… " # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldBlue}⚑ " # the number of stashed files/dir GIT_PROMPT_CLEAN="${BoldGreen}✔ " # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - GIT_PROMPT_COMMAND_OK="${Green}✔ " # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL - GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}" - GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}" - GIT_PROMPT_END_USER=" \n${White}${Time12a}${ResetColor} $ " - GIT_PROMPT_END_ROOT=" \n${White}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Default Ubuntu" \ No newline at end of file diff --git a/themes/Solarized.bgptheme b/themes/Solarized.bgptheme index 7825fd2..caf1ea8 100644 --- a/themes/Solarized.bgptheme +++ b/themes/Solarized.bgptheme @@ -1,51 +1,13 @@ # This theme for gitprompt.sh is optimized for the "Solarized Dark" and "Solarized Light" color schemes # tweaked for Ubuntu terminal fonts -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Yellow}●" # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldMagenta}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${Green}✔" # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - - GIT_PROMPT_COMMAND_OK="${Green}✔" # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL - GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}" - GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}" +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Solarized" + GIT_PROMPT_STAGED="${Yellow}●" + GIT_PROMPT_STASHED="${BoldMagenta}⚑ " + GIT_PROMPT_CLEAN="${Green}✔" GIT_PROMPT_END_USER=" \n${BoldBlue}${Time12a}${ResetColor} $ " GIT_PROMPT_END_ROOT=" \n${BoldBlue}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Solarized" \ No newline at end of file diff --git a/themes/Solarized_NoExitState.bgptheme b/themes/Solarized_NoExitState.bgptheme index a2108d7..77f8e50 100644 --- a/themes/Solarized_NoExitState.bgptheme +++ b/themes/Solarized_NoExitState.bgptheme @@ -1,51 +1,16 @@ # This theme for gitprompt.sh is optimized for the "Solarized Dark" and "Solarized Light" color schemes # without the indicator of the last command state -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Yellow}●" # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}…" # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldMagenta}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${Green}✔" # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - - GIT_PROMPT_COMMAND_OK="${Green}✔" # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘" # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Solarized NoExitState" + GIT_PROMPT_STAGED="${Yellow}●" + GIT_PROMPT_STASHED="${BoldMagenta}⚑ " + GIT_PROMPT_CLEAN="${Green}✔" + GIT_PROMPT_COMMAND_FAIL="${Red}✘" GIT_PROMPT_START_USER="${Yellow}${PathShort}${ResetColor}" GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}" GIT_PROMPT_END_USER=" \n${BoldBlue}${Time12a}${ResetColor} $ " GIT_PROMPT_END_ROOT=" \n${BoldBlue}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Solarized NoExitState" \ No newline at end of file diff --git a/themes/Solarized_NoExitState_Ubuntu.bgptheme b/themes/Solarized_NoExitState_Ubuntu.bgptheme index d8cab5e..ae47548 100644 --- a/themes/Solarized_NoExitState_Ubuntu.bgptheme +++ b/themes/Solarized_NoExitState_Ubuntu.bgptheme @@ -2,51 +2,18 @@ # without the indicator of the last command state # tweaked for Ubuntu terminal fonts -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Yellow}● " # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}… " # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldMagenta}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${Green}✔ " # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - - GIT_PROMPT_COMMAND_OK="${Green}✔ " # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘ " # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Solarized NoExitState Ubuntu" + GIT_PROMPT_STAGED="${Yellow}● " + GIT_PROMPT_UNTRACKED="${Cyan}… " + GIT_PROMPT_STASHED="${BoldMagenta}⚑ " + GIT_PROMPT_CLEAN="${Green}✔ " + GIT_PROMPT_COMMAND_OK="${Green}✔ " + GIT_PROMPT_COMMAND_FAIL="${Red}✘ " GIT_PROMPT_START_USER="${Yellow}${PathShort}${ResetColor}" GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}" GIT_PROMPT_END_USER=" \n${BoldBlue}${Time12a}${ResetColor} $ " GIT_PROMPT_END_ROOT=" \n${BoldBlue}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Solarized NoExitState Ubuntu" \ No newline at end of file diff --git a/themes/Solarized_Ubuntu.bgptheme b/themes/Solarized_Ubuntu.bgptheme index 3b7b146..a60a0ef 100644 --- a/themes/Solarized_Ubuntu.bgptheme +++ b/themes/Solarized_Ubuntu.bgptheme @@ -1,51 +1,15 @@ # This theme for gitprompt.sh is optimized for the "Solarized Dark" and "Solarized Light" color schemes # tweaked for Ubuntu terminal fonts -define_git_prompt_colors() { - Time12a="\$(date +%H:%M)" - PathShort="\w" - - # These are the color definitions used by gitprompt.sh - GIT_PROMPT_PREFIX="[" # start of the git info string - GIT_PROMPT_SUFFIX="]" # the end of the git info string - GIT_PROMPT_SEPARATOR="|" # separates each item - - GIT_PROMPT_BRANCH="${Magenta}" # the git branch that is active in the current directory - GIT_PROMPT_STAGED="${Yellow}● " # the number of staged files/directories - GIT_PROMPT_CONFLICTS="${Red}✖ " # the number of files in conflict - GIT_PROMPT_CHANGED="${Blue}✚ " # the number of changed files - - GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind - GIT_PROMPT_UNTRACKED="${Cyan}… " # the number of untracked files/dirs - GIT_PROMPT_STASHED="${BoldMagenta}⚑ " # the number of stashed files/dir - GIT_PROMPT_CLEAN="${Green}✔ " # a colored flag indicating a "clean" repo - - # For the command indicator, the placeholder _LAST_COMMAND_STATE_ - # will be replaced with the exit code of the last command - # e.g. - # GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0 - # GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of other than 0 - - GIT_PROMPT_COMMAND_OK="${Green}✔ " # indicator if the last command returned with an exit code of 0 - GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0 - - # template for displaying the current virtual environment - # use the placeholder _VIRTUALENV_ will be replaced with - # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) - GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) " - - # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL - GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}" - GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}" +override_git_prompt_colors() { + GIT_PROMPT_THEME_NAME="Solarized Ubuntu" + GIT_PROMPT_STAGED="${Yellow}● " + GIT_PROMPT_UNTRACKED="${Cyan}… " + GIT_PROMPT_STASHED="${BoldMagenta}⚑ " + GIT_PROMPT_CLEAN="${Green}✔ " + GIT_PROMPT_COMMAND_OK="${Green}✔ " GIT_PROMPT_END_USER=" \n${BoldBlue}${Time12a}${ResetColor} $ " GIT_PROMPT_END_ROOT=" \n${BoldBlue}${Time12a}${ResetColor} # " - - # Please do not add colors to these symbols - GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin" - GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin" - GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found } -if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then - define_git_prompt_colors -fi +reload_git_prompt_colors "Solarized Ubuntu" \ No newline at end of file