aks: resolved conflicts with original master

master
Alan Stebbens 11 years ago
commit a91bbe7231
  1. 10
      README.md
  2. 1
      git-prompt-colors.sh
  3. 35
      gitprompt.sh

@ -113,7 +113,15 @@ function prompt_callback {
- You can show an additional indicator at the start of the prompt, which shows - You can show an additional indicator at the start of the prompt, which shows
the result of the last executed command by setting the result of the last executed command by setting
``GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1`` before sourcing the gitprompt ``GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR=1`` before sourcing the gitprompt
script script.
If you want to display the exit code too, you can use the placeholder
``_LAST_COMMAND_STATE_`` in ``GIT_PROMPT_COMMAND_OK`` or ``GIT_PROMPT_COMMAND_FAIL``
in your ``.git-prompt-colors.sh``:
```sh
GIT_PROMPT_COMMAND_OK="${Green}✔-_LAST_COMMAND_STATE_ " # displays as ✔-0
GIT_PROMPT_COMMAND_FAIL="${Red}✘-_LAST_COMMAND_STATE_ " # displays as ✘-1 for exit code 1
```
- It is now possible to disable the fetching of the remote repository either - It is now possible to disable the fetching of the remote repository either
globally by setting ``GIT_PROMPT_FETCH_REMOTE_STATUS=0`` in your .bashrc or globally by setting ``GIT_PROMPT_FETCH_REMOTE_STATUS=0`` in your .bashrc or

@ -37,4 +37,3 @@ define_git_prompt_colors() {
if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then if [[ -z "$GIT_PROMPT_SEPARATOR" || -z "$GIT_PROMPT_COMMAND_OK" ]]; then
define_git_prompt_colors define_git_prompt_colors
fi fi

@ -69,7 +69,6 @@ function gp_maybe_set_envar_to_path(){
function git_prompt_config() function git_prompt_config()
{ {
#Checking if root to change output #Checking if root to change output
_isroot=false _isroot=false
[[ $UID -eq 0 ]] && _isroot=true [[ $UID -eq 0 ]] && _isroot=true
@ -94,6 +93,17 @@ function git_prompt_config()
echo 1>&2 "Cannot find git-prompt-colors.sh!" echo 1>&2 "Cannot find git-prompt-colors.sh!"
fi fi
if [ "$GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR" = 1 ]; then
if [ $GIT_PROMPT_LAST_COMMAND_STATE = 0 ]; then
LAST_COMMAND_INDICATOR="${GIT_PROMPT_COMMAND_OK}";
else
LAST_COMMAND_INDICATOR="${GIT_PROMPT_COMMAND_FAIL}";
fi
# replace _LAST_COMMAND_STATE_ token with the actual state
LAST_COMMAND_INDICATOR="${LAST_COMMAND_INDICATOR/_LAST_COMMAND_STATE_/${GIT_PROMPT_LAST_COMMAND_STATE}}"
fi
# Do this only once to define PROMPT_START and PROMPT_END # Do this only once to define PROMPT_START and PROMPT_END
if [[ -z "$PROMPT_START" || -z "$PROMPT_END" ]]; then if [[ -z "$PROMPT_START" || -z "$PROMPT_END" ]]; then
@ -155,9 +165,11 @@ function git_prompt_config()
fi fi
} }
function setGitPrompt() { function setLastCommandState() {
LAST_COMMAND_STATE=$? GIT_PROMPT_LAST_COMMAND_STATE=$?
}
function setGitPrompt() {
local EMPTY_PROMPT local EMPTY_PROMPT
local __GIT_STATUS_CMD local __GIT_STATUS_CMD
@ -288,7 +300,7 @@ function prompt_callback_default {
return return
} }
function run { function gp_install_prompt {
if [ "`type -t prompt_callback`" = 'function' ]; then if [ "`type -t prompt_callback`" = 'function' ]; then
prompt_callback="prompt_callback" prompt_callback="prompt_callback"
else else
@ -317,8 +329,21 @@ function run {
esac esac
fi fi
if [ "x${GIT_PROMPT_SHOW_LAST_COMMAND_INDICATOR}" == "x1" ]; then
local setLastCommandStateEntry="setLastCommandState"
case ";$PROMPT_COMMAND;" in
*";$setLastCommandStateEntry;"*)
# echo "PROMPT_COMMAND already contains: $setLastCommandStateEntry"
:;;
*)
PROMPT_COMMAND="$setLastCommandStateEntry;$PROMPT_COMMAND"
# echo "PROMPT_COMMAND does not contain: $setLastCommandStateEntry"
;;
esac
fi
git_prompt_dir git_prompt_dir
source "$__GIT_PROMPT_DIR/git-prompt-help.sh" source "$__GIT_PROMPT_DIR/git-prompt-help.sh"
} }
run gp_install_prompt

Loading…
Cancel
Save