Skip to content

Commit c043179

Browse files
committed
gitstatus.sh was not theme aware
fixes #83
1 parent 62efaa9 commit c043179

File tree

2 files changed

+13
-41
lines changed

2 files changed

+13
-41
lines changed

gitprompt.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ function checkUpstream() {
326326
fi
327327
}
328328

329+
function replaceSymbols()
330+
{
331+
local VALUE=${1/_AHEAD_/${GIT_PROMPT_SYMBOLS_AHEAD}}
332+
local VALUE1=${VALUE/_BEHIND_/${GIT_PROMPT_SYMBOLS_BEHIND}}
333+
334+
echo ${VALUE1/_PREHASH_/${GIT_PROMPT_SYMBOLS_PREHASH}}
335+
}
336+
329337
function updatePrompt() {
330338
local LAST_COMMAND_INDICATOR
331339
local PROMPT_LEADING_SPACE
@@ -339,8 +347,8 @@ function updatePrompt() {
339347
local -a GitStatus
340348
GitStatus=($("$__GIT_STATUS_CMD" 2>/dev/null))
341349

342-
local GIT_BRANCH=${GitStatus[0]}
343-
local GIT_REMOTE=${GitStatus[1]}
350+
local GIT_BRANCH=$(replaceSymbols ${GitStatus[0]})
351+
local GIT_REMOTE="$(replaceSymbols ${GitStatus[1]})"
344352
if [[ "." == "$GIT_REMOTE" ]]; then
345353
unset GIT_REMOTE
346354
fi

gitstatus.sh

+3-39
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,6 @@ if [ -z "${__GIT_PROMPT_DIR}" ]; then
1919
__GIT_PROMPT_DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
2020
fi
2121

22-
if [[ -z "$__GIT_PROMPT_COLORS_FILE" ]]; then
23-
for dir in "$HOME" "$__GIT_PROMPT_DIR" ; do
24-
for pfx in '.' '' ; do
25-
file="$dir/${pfx}git-prompt-colors.sh"
26-
if [[ -f "$file" ]]; then
27-
__GIT_PROMPT_COLORS_FILE="$file"
28-
break 2
29-
fi
30-
done
31-
done
32-
fi
33-
34-
# if the envar is defined, source the file for custom colors
35-
if [[ -n "$__GIT_PROMPT_COLORS_FILE" && -f "$__GIT_PROMPT_COLORS_FILE" ]]; then
36-
source "$__GIT_PROMPT_COLORS_FILE"
37-
fi
38-
39-
# change those symbols to whatever you prefer
40-
if [[ -n "${GIT_PROMPT_SYMBOLS_AHEAD}" ]]; then
41-
symbols_ahead="${GIT_PROMPT_SYMBOLS_AHEAD}"
42-
else
43-
symbols_ahead='↑·'
44-
fi
45-
46-
if [[ -n "${GIT_PROMPT_SYMBOLS_BEHIND}" ]]; then
47-
symbols_behind="${GIT_PROMPT_SYMBOLS_BEHIND}"
48-
else
49-
symbols_behind='↓·'
50-
fi
51-
52-
if [[ -n "${GIT_PROMPT_SYMBOLS_PREHASH}" ]]; then
53-
symbols_prehash=':'
54-
else
55-
symbols_prehash="${GIT_PROMPT_SYMBOLS_PREHASH}"
56-
fi
57-
5822
gitsym=`git symbolic-ref HEAD`
5923

6024
# if "fatal: Not a git repo .., then exit
@@ -93,7 +57,7 @@ if [[ -z "$branch" ]]; then
9357
if [[ -n "$tag" ]]; then
9458
branch="$tag"
9559
else
96-
branch="${symbols_prehash}`git rev-parse --short HEAD`"
60+
branch="_PREHASH_`git rev-parse --short HEAD`"
9761
fi
9862
else
9963
remote_name=`git config branch.${branch}.remote`
@@ -126,10 +90,10 @@ else
12690
num_ahead=`count_lines "$revgit" "^>"`
12791
num_behind=$(( num_revs - num_ahead ))
12892
if (( num_behind > 0 )) ; then
129-
remote="${remote}${symbols_behind}${num_behind}"
93+
remote="${remote}_BEHIND_${num_behind}"
13094
fi
13195
if (( num_ahead > 0 )) ; then
132-
remote="${remote}${symbols_ahead}${num_ahead}"
96+
remote="${remote}_AHEAD_${num_ahead}"
13397
fi
13498
fi
13599

0 commit comments

Comments
 (0)