diff --git a/README.md b/README.md index 756186c0..2fe64fed 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,34 @@ git clone https://github.com/magicmonty/bash-git-prompt.git .bash-git-prompt # GIT_PROMPT_END=... # uncomment for custom prompt end sequence # as last entry source the gitprompt script + # GIT_PROMPT_THEME=Custom # use custom .git-prompt-colors.sh + # GIT_PROMPT_THEME=Solarized # use theme optimized for solarized color scheme source ~/.bash-git-prompt/gitprompt.sh ``` - `cd` to a git repository and test it! +#### Themes + +The most settings are now stored in theme files. To select a theme, set the variable `GIT_PROMPT_THEME` to the name +of the theme located in `/themes` without the extension `.bgptheme` like this: + +```sh +GIT_PROMPT_THEME=Solarized +``` + +If you set `GIT_PROMPT_THEME` to `Custom`, then the `.git-prompt-colors.sh` in the home directory will be used. +This file can now be generated with the command `git_prompt_make_custom_theme []`. If the name of +the base theme is ommitted or the theme file is not found, then the Default theme is used. If you have already a custom +`.git-prompt-colors.sh` in your home directory, a error message will be shown. + +You can display a list of available themes with `git_prompt_list_themes` (the current theme is highlighted) + +**If you omit the `GIT_PROMPT_THEME` variable, the Default theme is used or, if you have a custom `.git-prompt-colors.sh` +in your home directory, then the Custom theme is used.** + +#### Further customizations + - You can define `GIT_PROMPT_START` and `GIT_PROMPT_END` to tweak your prompt. - The default colors are defined within `prompt-colors.sh`, which is sourced by diff --git a/git-prompt-help.sh b/git-prompt-help.sh index 8b9b390d..d1fe7510 100755 --- a/git-prompt-help.sh +++ b/git-prompt-help.sh @@ -3,8 +3,8 @@ # being displayed. git_prompt_help() { - source prompt-colors.sh - source git-prompt-colors.sh + source ${__GIT_PROMPT_DIR}/prompt-colors.sh + source themes/Default.bgptheme cat <|] diff --git a/gitprompt.sh b/gitprompt.sh index cc71eef1..a172acbd 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -22,6 +22,100 @@ function git_prompt_dir() fi } +function echoc() { + echo -e "${1}$2${ResetColor}" | sed 's/\\\]//g' | sed 's/\\\[//g' +} + +function get_theme() +{ + local CUSTOM_THEME_FILE="${HOME}/.git-prompt-colors.sh" + local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" + + if [[ -z ${GIT_PROMPT_THEME} ]]; then + if [[ -r $CUSTOM_THEME_FILE ]]; then + GIT_PROMPT_THEME="Custom" + __GIT_PROMPT_THEME_FILE=$CUSTOM_THEME_FILE + else + GIT_PROMPT_THEME="Default" + __GIT_PROMPT_THEME_FILE=$DEFAULT_THEME_FILE + fi + else + if [[ "${GIT_PROMPT_THEME}" = "Custom" ]]; then + GIT_PROMPT_THEME="Custom" + __GIT_PROMPT_THEME_FILE=$CUSTOM_THEME_FILE + + if [[ !(-r $__GIT_PROMPT_THEME_FILE) ]]; then + GIT_PROMPT_THEME="Default" + __GIT_PROMPT_THEME_FILE=$DEFAULT_THEME_FILE + fi + else + local theme="" + + # use default theme, if theme was not found + for themefile in `ls $__GIT_PROMPT_DIR/themes`; do + if [[ "${themefile}" = "${GIT_PROMPT_THEME}.bgptheme" ]]; then + theme=$GIT_PROMPT_THEME + fi + done + + if [[ "${theme}" = "" ]]; then + GIT_PROMPT_THEME="Default" + fi + + __GIT_PROMPT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/${GIT_PROMPT_THEME}.bgptheme" + fi + fi +} + +function git_prompt_list_themes() +{ + local oldTheme + local oldThemeFile + + git_prompt_dir + get_theme + + for themefile in `ls $__GIT_PROMPT_DIR/themes`; do + local theme="$(basename $themefile .bgptheme)" + + if [[ "${GIT_PROMPT_THEME}" = "${theme}" ]]; then + echoc ${Red} "*${theme}" + else + echo $theme + fi + done + + if [[ "${GIT_PROMPT_THEME}" = "Custom" ]]; then + echoc ${Magenta} "*Custom" + else + echoc ${Blue} "Custom" + fi +} + +function git_prompt_make_custom_theme() { + if [[ -r "${HOME}/.git-prompt-colors.sh" ]]; then + echoc ${Red} "You alread have created a custom theme!" + else + git_prompt_dir + + local base="Default" + if [[ -n $1 && -r "${__GIT_PROMPT_DIR}/themes/${1}.bgptheme" ]]; then + base=$1 + echoc ${Green} "Using theme ${Magenta}\"${base}\"${Green} as base theme!" + else + echoc ${Green} "Using theme ${Magenta}\"Default\"${Green} as base theme!" + fi + + if [[ "${base}" = "Custom" ]]; then + echoc ${Red} "You cannot use the custom theme as base" + 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" + fi + fi +} + # gp_set_file_var ENVAR SOMEFILE # # If ENVAR is set, check that it's value exists as a readable file. Otherwise, @@ -99,11 +193,8 @@ 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 - if gp_set_file_var __GIT_PROMPT_COLORS_FILE git-prompt-colors.sh ; then - source "$__GIT_PROMPT_COLORS_FILE" - else - echo 1>&2 "Cannot find git-prompt-colors.sh!" - fi + get_theme + source "$__GIT_PROMPT_THEME_FILE" if [ $GIT_PROMPT_LAST_COMMAND_STATE = 0 ]; then LAST_COMMAND_INDICATOR="$GIT_PROMPT_COMMAND_OK"; diff --git a/git-prompt-colors.sh b/themes/Default.bgptheme similarity index 93% rename from git-prompt-colors.sh rename to themes/Default.bgptheme index 9d6a7ed6..fbb56ab6 100644 --- a/git-prompt-colors.sh +++ b/themes/Default.bgptheme @@ -1,4 +1,4 @@ -# These are the color definitions used by gitprompt.sh +# This is the default theme for gitprompt.sh define_git_prompt_colors() { Time12a="\$(date +%H:%M)" @@ -26,7 +26,7 @@ define_git_prompt_colors() { # 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 + 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 diff --git a/themes/Default_NoExitState.bgptheme b/themes/Default_NoExitState.bgptheme new file mode 100644 index 00000000..e2387494 --- /dev/null +++ b/themes/Default_NoExitState.bgptheme @@ -0,0 +1,51 @@ +# 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 + 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 diff --git a/themes/Default_NoExitState_Ubuntu.bgptheme b/themes/Default_NoExitState_Ubuntu.bgptheme new file mode 100644 index 00000000..1f7a1e76 --- /dev/null +++ b/themes/Default_NoExitState_Ubuntu.bgptheme @@ -0,0 +1,52 @@ +# This is the default theme for gitprompt.sh +# 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="${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 diff --git a/themes/Default_Ubuntu.bgptheme b/themes/Default_Ubuntu.bgptheme new file mode 100644 index 00000000..a1b54b05 --- /dev/null +++ b/themes/Default_Ubuntu.bgptheme @@ -0,0 +1,51 @@ +# 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 + 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 diff --git a/themes/Solarized.bgptheme b/themes/Solarized.bgptheme new file mode 100644 index 00000000..7825fd2b --- /dev/null +++ b/themes/Solarized.bgptheme @@ -0,0 +1,51 @@ +# 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}" + 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 diff --git a/themes/Solarized_NoExitState.bgptheme b/themes/Solarized_NoExitState.bgptheme new file mode 100644 index 00000000..a2108d7b --- /dev/null +++ b/themes/Solarized_NoExitState.bgptheme @@ -0,0 +1,51 @@ +# 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 + 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 diff --git a/themes/Solarized_NoExitState_Ubuntu.bgptheme b/themes/Solarized_NoExitState_Ubuntu.bgptheme new file mode 100644 index 00000000..d8cab5e7 --- /dev/null +++ b/themes/Solarized_NoExitState_Ubuntu.bgptheme @@ -0,0 +1,52 @@ +# This theme for gitprompt.sh is optimized for the "Solarized Dark" and "Solarized Light" color schemes +# 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 + 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 diff --git a/themes/Solarized_Ubuntu.bgptheme b/themes/Solarized_Ubuntu.bgptheme new file mode 100644 index 00000000..3b7b1462 --- /dev/null +++ b/themes/Solarized_Ubuntu.bgptheme @@ -0,0 +1,51 @@ +# 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}" + 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