Skip to content

Commit

Permalink
gitstatus.sh was not theme aware
Browse files Browse the repository at this point in the history
fixes #83
  • Loading branch information
magicmonty committed Oct 7, 2014
1 parent 62efaa9 commit c043179
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 41 deletions.
12 changes: 10 additions & 2 deletions gitprompt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
42 changes: 3 additions & 39 deletions gitstatus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c043179

Please sign in to comment.