Made gitstatus variables for `symbols_ahead`, `symbols_behind` and `symbols_prehash` configurable via `git-prompt-colors.sh`

Fixes #51

The new variables are:

```bash
GIT_STATUS_SYMBOLS_AHEAD
GIT_STATUS_SYMBOLS_BEHIND
GIT_STATUS_SYMBOLS_PREHASH
```
master
Martin Gondermann 12 years ago
parent 557d395303
commit 4153ec7ed7
  1. 7
      git-prompt-colors.sh
  2. 5
      gitprompt.sh
  3. 47
      gitstatus.sh

@ -7,7 +7,12 @@
GIT_PROMPT_STAGED="${Red}" # the number of staged files/directories
GIT_PROMPT_CONFLICTS="${Red}" # the number of files in conflict
GIT_PROMPT_CHANGED="${Blue}" # the number of changed files
GIT_PROMPT_REMOTE=" " # the remote branch name (if any)
GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind
GIT_PROMPT_UNTRACKED="${Cyan}" # the number of untracked files/dirs
GIT_PROMPT_STASHED="${BoldBlue}" # the number of stashed files/dir
GIT_PROMPT_CLEAN="${BoldGreen}" # a colored flag indicating a "clean" repo
# Please do not add colors to these symbols
GIT_PROMPT_SYMBOLS_AHEAD="↑·" # The symbol for "n versions ahead of origin"
GIT_PROMPT_SYMBOLS_BEHIND="↓·" # The symbol for "n versions behind of origin"
GIT_PROMPT_SYMBOLS_PREHASH=":" # Written before hash of commit, if no name could be found

@ -77,6 +77,11 @@ function git_prompt_config()
GIT_PROMPT_UNTRACKED="${Cyan}"
GIT_PROMPT_STASHED="${BoldBlue}"
GIT_PROMPT_CLEAN="${BoldGreen}"
# Please do not add colors to these symbols
GIT_PROMPT_SYMBOLS_AHEAD="↑·"
GIT_PROMPT_SYMBOLS_BEHIND="↓·"
GIT_PROMPT_SYMBOLS_PREHASH=":"
fi
# Various variables you might want for your PS1 prompt instead

@ -9,10 +9,51 @@
count_lines() { echo "$1" | egrep -c "^$2" ; }
all_lines() { echo "$1" | grep -v "^$" | wc -l ; }
if [ -z "${__GIT_PROMPT_DIR}" ]; then
SOURCE="${BASH_SOURCE[0]}"
while [ -h "${SOURCE}" ]; do
DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
SOURCE="$(readlink "${SOURCE}")"
[[ $SOURCE != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
__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
symbols_ahead='↑·'
symbols_behind='↓·'
symbols_prehash=':'
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`

Loading…
Cancel
Save