diff --git a/git-prompt-colors.sh b/git-prompt-colors.sh index 686804c..1e8c423 100644 --- a/git-prompt-colors.sh +++ b/git-prompt-colors.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 diff --git a/gitprompt.sh b/gitprompt.sh index 98ba58f..ca5c842 100755 --- a/gitprompt.sh +++ b/gitprompt.sh @@ -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 diff --git a/gitstatus.sh b/gitstatus.sh index a8fe5a1..e64df13 100755 --- a/gitstatus.sh +++ b/gitstatus.sh @@ -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`