|
|
|
@ -1,14 +1,12 @@ |
|
|
|
#!/bin/sh |
|
|
|
#!/bin/sh |
|
|
|
|
|
|
|
|
|
|
|
function async_run() |
|
|
|
function async_run() { |
|
|
|
{ |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
eval "$@" &> /dev/null |
|
|
|
eval "$@" &> /dev/null |
|
|
|
}& |
|
|
|
}& |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function git_prompt_dir() |
|
|
|
function git_prompt_dir() { |
|
|
|
{ |
|
|
|
|
|
|
|
# assume the gitstatus.sh 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 |
|
|
|
# code thanks to http://stackoverflow.com/questions/59895 |
|
|
|
if [ -z "$__GIT_PROMPT_DIR" ]; then |
|
|
|
if [ -z "$__GIT_PROMPT_DIR" ]; then |
|
|
|
@ -26,8 +24,7 @@ function echoc() { |
|
|
|
echo -e "${1}$2${ResetColor}" | sed 's/\\\]//g' | sed 's/\\\[//g' |
|
|
|
echo -e "${1}$2${ResetColor}" | sed 's/\\\]//g' | sed 's/\\\[//g' |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function get_theme() |
|
|
|
function get_theme() { |
|
|
|
{ |
|
|
|
|
|
|
|
local CUSTOM_THEME_FILE="${HOME}/.git-prompt-colors.sh" |
|
|
|
local CUSTOM_THEME_FILE="${HOME}/.git-prompt-colors.sh" |
|
|
|
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" |
|
|
|
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" |
|
|
|
|
|
|
|
|
|
|
|
@ -67,16 +64,14 @@ function get_theme() |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function git_prompt_load_theme() |
|
|
|
function git_prompt_load_theme() { |
|
|
|
{ |
|
|
|
|
|
|
|
get_theme |
|
|
|
get_theme |
|
|
|
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" |
|
|
|
local DEFAULT_THEME_FILE="${__GIT_PROMPT_DIR}/themes/Default.bgptheme" |
|
|
|
source "${DEFAULT_THEME_FILE}" |
|
|
|
source "${DEFAULT_THEME_FILE}" |
|
|
|
source "${__GIT_PROMPT_THEME_FILE}" |
|
|
|
source "${__GIT_PROMPT_THEME_FILE}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function git_prompt_list_themes() |
|
|
|
function git_prompt_list_themes() { |
|
|
|
{ |
|
|
|
|
|
|
|
local oldTheme |
|
|
|
local oldTheme |
|
|
|
local oldThemeFile |
|
|
|
local oldThemeFile |
|
|
|
|
|
|
|
|
|
|
|
@ -160,7 +155,7 @@ function gp_set_file_var() { |
|
|
|
# return 0 (true) if any FILEPATH is readable, set ENVAR to it |
|
|
|
# return 0 (true) if any FILEPATH is readable, set ENVAR to it |
|
|
|
# return 1 (false) if not |
|
|
|
# return 1 (false) if not |
|
|
|
|
|
|
|
|
|
|
|
function gp_maybe_set_envar_to_path(){ |
|
|
|
function gp_maybe_set_envar_to_path() { |
|
|
|
local envar="$1" |
|
|
|
local envar="$1" |
|
|
|
shift |
|
|
|
shift |
|
|
|
local file |
|
|
|
local file |
|
|
|
@ -203,8 +198,7 @@ gp_format_exit_status() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
@ -225,7 +219,7 @@ function git_prompt_config() |
|
|
|
|
|
|
|
|
|
|
|
git_prompt_load_theme |
|
|
|
git_prompt_load_theme |
|
|
|
|
|
|
|
|
|
|
|
if [ "`type -t prompt_callback`" = 'function' ]; then |
|
|
|
if is_function prompt_callback; then |
|
|
|
prompt_callback="prompt_callback" |
|
|
|
prompt_callback="prompt_callback" |
|
|
|
else |
|
|
|
else |
|
|
|
prompt_callback="prompt_callback_default" |
|
|
|
prompt_callback="prompt_callback_default" |
|
|
|
@ -424,8 +418,7 @@ function checkUpstream() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function replaceSymbols() |
|
|
|
function replaceSymbols() { |
|
|
|
{ |
|
|
|
|
|
|
|
if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then |
|
|
|
if [[ -z ${GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING} ]]; then |
|
|
|
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING=L |
|
|
|
GIT_PROMPT_SYMBOLS_NO_REMOTE_TRACKING=L |
|
|
|
fi |
|
|
|
fi |
|
|
|
@ -524,6 +517,12 @@ function updatePrompt() { |
|
|
|
PS1="${NEW_PROMPT//_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}" |
|
|
|
PS1="${NEW_PROMPT//_LAST_COMMAND_INDICATOR_/${LAST_COMMAND_INDICATOR}}" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use exit status from declare command to determine whether input argument is a |
|
|
|
|
|
|
|
# bash function |
|
|
|
|
|
|
|
function is_function { |
|
|
|
|
|
|
|
declare -Ff "$1" >/dev/null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function prompt_callback_default { |
|
|
|
function prompt_callback_default { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|