Skip to content

Commit

Permalink
There was _LAST_COMMAND_INDICATOR_ being printed in prompt output on …
Browse files Browse the repository at this point in the history
…root user

Fixes #96
  • Loading branch information
magicmonty committed Nov 14, 2014
1 parent 1893c82 commit cc97adf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function git_prompt_config()
fi

# replace _LAST_COMMAND_STATE_ token with the actual state
LAST_COMMAND_INDICATOR="${LAST_COMMAND_INDICATOR/_LAST_COMMAND_STATE_/${GIT_PROMPT_LAST_COMMAND_STATE}}"
LAST_COMMAND_INDICATOR="${LAST_COMMAND_INDICATOR//_LAST_COMMAND_STATE_/${GIT_PROMPT_LAST_COMMAND_STATE}}"

# Do this only once to define PROMPT_START and PROMPT_END

Expand Down Expand Up @@ -254,14 +254,14 @@ function git_prompt_config()
local ps=""
if [[ -n "$VIRTUAL_ENV" ]]; then
VENV=$(basename "${VIRTUAL_ENV}")
ps="${ps}${GIT_PROMPT_VIRTUALENV/_VIRTUALENV_/${VENV}}"
ps="${ps}${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
fi
if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
VENV=$(basename "${CONDA_DEFAULT_ENV}")
ps="${ps}${GIT_PROMPT_VIRTUALENV/_VIRTUALENV_/${VENV}}"
ps="${ps}${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
fi
ps="$ps$PROMPT_START$($prompt_callback)$PROMPT_END"
EMPTY_PROMPT="${ps/_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}"
EMPTY_PROMPT="${ps//_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}"
fi

# fetch remote revisions every other $GIT_PROMPT_FETCH_TIMEOUT (default 5) minutes
Expand Down Expand Up @@ -361,11 +361,11 @@ function replaceSymbols()
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}}
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 ${VALUE2/_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}}
echo ${VALUE2//_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}}
}

function updatePrompt() {
Expand Down Expand Up @@ -438,20 +438,20 @@ function updatePrompt() {
NEW_PROMPT=""
if [[ -n "$VIRTUAL_ENV" ]]; then
VENV=$(basename "${VIRTUAL_ENV}")
NEW_PROMPT="$NEW_PROMPT${GIT_PROMPT_VIRTUALENV/_VIRTUALENV_/${VENV}}"
NEW_PROMPT="$NEW_PROMPT${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
fi

if [[ -n "$CONDA_DEFAULT_ENV" ]]; then
VENV=$(basename "${CONDA_DEFAULT_ENV}")
NEW_PROMPT="$NEW_PROMPT${GIT_PROMPT_VIRTUALENV/_VIRTUALENV_/${VENV}}"
NEW_PROMPT="$NEW_PROMPT${GIT_PROMPT_VIRTUALENV//_VIRTUALENV_/${VENV}}"
fi

NEW_PROMPT="$NEW_PROMPT$PROMPT_START$($prompt_callback)$STATUS$PROMPT_END"
else
NEW_PROMPT="$EMPTY_PROMPT"
fi

PS1="${NEW_PROMPT/_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}"
PS1="${NEW_PROMPT//_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}"
}

function prompt_callback_default {
Expand Down
2 changes: 1 addition & 1 deletion themes/Default.bgptheme
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define_undefined_git_prompt_colors() {

# _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_ROOT} ]]; then GIT_PROMPT_START_ROOT="_LAST_COMMAND_INDICATOR_ ${GIT_PROMPT_START_USER}"; fi
if [[ -z ${GIT_PROMPT_START_ROOT} ]]; then GIT_PROMPT_START_ROOT="${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

Expand Down

0 comments on commit cc97adf

Please sign in to comment.