diff --git a/gitprompt.sh b/gitprompt.sh index c577fe5e..d824692a 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -326,6 +326,14 @@ function checkUpstream() { fi } +function replaceSymbols() +{ + local VALUE=${1/_AHEAD_/${GIT_PROMPT_SYMBOLS_AHEAD}} + local VALUE1=${VALUE/_BEHIND_/${GIT_PROMPT_SYMBOLS_BEHIND}} + + echo ${VALUE1/_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}} +} + function updatePrompt() { local LAST_COMMAND_INDICATOR local PROMPT_LEADING_SPACE @@ -339,8 +347,8 @@ function updatePrompt() { local -a GitStatus GitStatus=($("$__GIT_STATUS_CMD" 2>/dev/null)) - local GIT_BRANCH=${GitStatus[0]} - local GIT_REMOTE=${GitStatus[1]} + local GIT_BRANCH=$(replaceSymbols ${GitStatus[0]}) + local GIT_REMOTE="$(replaceSymbols ${GitStatus[1]})" if [[ "." == "$GIT_REMOTE" ]]; then unset GIT_REMOTE fi diff --git a/gitstatus.sh b/gitstatus.sh index ba210b55..565c32b0 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -19,42 +19,6 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then __GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )" fi -if [[ -z "$__GIT_PROMPT_COLORS_FILE" ]]; then - for dir in "$HOME" "$__GIT_PROMPT_DIR" ; do - for pfx in '.' '' ; do - file="$dir/${pfx}git-prompt-colors.sh" - if [[ -f "$file" ]]; then - __GIT_PROMPT_COLORS_FILE="$file" - break 2 - fi - done - done -fi - -# if the envar is defined, source the file for custom colors -if [[ -n "$__GIT_PROMPT_COLORS_FILE" && -f "$__GIT_PROMPT_COLORS_FILE" ]]; then - source "$__GIT_PROMPT_COLORS_FILE" -fi - -# change those symbols to whatever you prefer -if [[ -n "${GIT_PROMPT_SYMBOLS_AHEAD}" ]]; then - symbols_ahead="${GIT_PROMPT_SYMBOLS_AHEAD}" -else - symbols_ahead='↑·' -fi - -if [[ -n "${GIT_PROMPT_SYMBOLS_BEHIND}" ]]; then - symbols_behind="${GIT_PROMPT_SYMBOLS_BEHIND}" -else - symbols_behind='↓·' -fi - -if [[ -n "${GIT_PROMPT_SYMBOLS_PREHASH}" ]]; then - symbols_prehash=':' -else - symbols_prehash="${GIT_PROMPT_SYMBOLS_PREHASH}" -fi - gitsym=`git symbolic-ref HEAD` # if "fatal: Not a git repo .., then exit @@ -93,7 +57,7 @@ if [[ -z "$branch" ]]; then if [[ -n "$tag" ]]; then branch="$tag" else - branch="${symbols_prehash}`git rev-parse --short HEAD`" + branch="_PREHASH_`git rev-parse --short HEAD`" fi else remote_name=`git config branch.${branch}.remote` @@ -126,10 +90,10 @@ else num_ahead=`count_lines "$revgit" "^>"` num_behind=$(( num_revs - num_ahead )) if (( num_behind > 0 )) ; then - remote="${remote}${symbols_behind}${num_behind}" + remote="${remote}_BEHIND_${num_behind}" fi if (( num_ahead > 0 )) ; then - remote="${remote}${symbols_ahead}${num_ahead}" + remote="${remote}_AHEAD_${num_ahead}" fi fi