Added environment variable GIT_PROMPT_STATUS_COMMAND that can point out a custom gitstatus.sh script if needed.

master
oGre 10 years ago
parent 47f4aca1f8
commit 09c98facb6
  1. 5
      gitprompt.sh
  2. 0
      gitstatus_pre-1.7.10.sh
  3. 11
      themes/Default.bgptheme

@ -282,8 +282,8 @@ function git_prompt_config() {
fi fi
if [[ -z "$__GIT_STATUS_CMD" ]] ; then # if GIT_STATUS_CMD not defined.. if [[ -z "$__GIT_STATUS_CMD" ]] ; then # if GIT_STATUS_CMD not defined..
git_prompt_dir git_prompt_dir
if ! gp_maybe_set_envar_to_path __GIT_STATUS_CMD "$__GIT_PROMPT_DIR/gitstatus.sh" ; then if ! gp_maybe_set_envar_to_path __GIT_STATUS_CMD "$__GIT_PROMPT_DIR/$GIT_PROMPT_STATUS_COMMAND" ; then
echo 1>&2 "Cannot find gitstatus.sh!" echo 1>&2 "Cannot find $GIT_PROMPT_STATUS_COMMAND!"
fi fi
# __GIT_STATUS_CMD defined # __GIT_STATUS_CMD defined
fi fi
@ -520,7 +520,6 @@ function gp_add_virtualenv_to_prompt {
function is_function { function is_function {
declare -Ff "$1" >/dev/null; declare -Ff "$1" >/dev/null;
} }
#Helper function that truncates $PWD depending on window width #Helper function that truncates $PWD depending on window width
function gp_truncate_pwd { function gp_truncate_pwd {
local newPWD="${PWD/#$HOME/~}" local newPWD="${PWD/#$HOME/~}"

@ -16,6 +16,7 @@ unset_git_prompt_colors() {
unset GIT_PROMPT_CLEAN unset GIT_PROMPT_CLEAN
unset GIT_PROMPT_COMMAND_OK unset GIT_PROMPT_COMMAND_OK
unset GIT_PROMPT_COMMAND_FAIL unset GIT_PROMPT_COMMAND_FAIL
unset GIT_PROMPT_STATUS_COMMAND
unset GIT_PROMPT_VIRTUALENV unset GIT_PROMPT_VIRTUALENV
unset GIT_PROMPT_START_USER unset GIT_PROMPT_START_USER
unset GIT_PROMPT_START_ROOT unset GIT_PROMPT_START_ROOT
@ -51,7 +52,7 @@ define_undefined_git_prompt_colors() {
if [[ -z ${GIT_PROMPT_STASHED} ]]; then GIT_PROMPT_STASHED="${BoldBlue}⚑ "; fi # the number of stashed files/dir 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 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_ # For the command indicator, the placeholder _LAST_COMMAND_STATE_
# will be replaced with the exit code of the last command # will be replaced with the exit code of the last command
# e.g. # 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_OK="${Green}✔-_LAST_COMMAND_STATE_ " # indicator if the last command returned with an exit code of 0
@ -60,11 +61,13 @@ define_undefined_git_prompt_colors() {
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_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 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
if [[ -z ${GIT_PROMPT_STATUS_COMMAND} ]]; then GIT_PROMPT_STATUS_COMMAND="gitstatus.sh"; fi # Point out the command to get the gitstatus from
# template for displaying the current virtual environment # template for displaying the current virtual environment
# use the placeholder _VIRTUALENV_ will be replaced with # use the placeholder _VIRTUALENV_ will be replaced with
# the name of the current virtual environment (currently CONDA and VIRTUAL_ENV) # the name of the current virtual environment (currently CONDA and VIRTUAL_ENV)
if [[ -z ${GIT_PROMPT_VIRTUALENV} ]]; then GIT_PROMPT_VIRTUALENV="(${Blue}_VIRTUALENV_${ResetColor}) "; fi 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 # _LAST_COMMAND_INDICATOR_ will be replaced by the appropriate GIT_PROMPT_COMMAND_OK OR GIT_PROMPT_COMMAND_FAIL
if [[ -z ${GIT_PROMPT_START_USER} ]]; then GIT_PROMPT_START_USER="_LAST_COMMAND_INDICATOR_ ${Yellow}${PathShort}${ResetColor}"; fi 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="${GIT_PROMPT_START_USER}"; fi if [[ -z ${GIT_PROMPT_START_ROOT} ]]; then GIT_PROMPT_START_ROOT="${GIT_PROMPT_START_USER}"; fi
@ -75,7 +78,7 @@ define_undefined_git_prompt_colors() {
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_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_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_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 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 # call only from theme file

Loading…
Cancel
Save