removed bash-init, added simple git branch indicator

This commit is contained in:
Martinez 2015-02-26 22:01:11 +01:00
parent e5d1094566
commit 63d4b8c1fd
2 changed files with 22 additions and 80 deletions

View file

@ -16,14 +16,34 @@ function strlen {
}
function precmd {
local OVER_OPTS RAW_DATA LOGIN_PART STATS_PART DATA TOP_LEFT TOP_RIGHT PADDING PADDING_SIZE
local OVER_OPTS RAW_DATA LOGIN_PART STATS_PART DATA TOP_LEFT TOP_RIGHT PADDING PADDING_SIZE GIT_BRANCH COLOR
set -A OVER_OPTS ${(s. .)OVER_PROMPT_OPTS}
PS1="$(print "%(?.%{\e[1;36m%}.%{\e[1;31m%}%?%{\e[0m%}:%{\e[1;31m%})%(\!.#.$)%{\e[0m%} ")"
RAW_DATA="$(/usr/share/over-prompt/data $OVER_OPTS[1] $OVER_OPTS[2] $OVER_OPTS[3])"
if [ -n "$RAW_DATA" ]; then
GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD 2> /dev/null)"
if [[ -n "$GIT_BRANCH" ]]; then
# rebuild index
git update-index -q --ignore-submodules --refresh
# so that I can check if there are unstaged changes
git diff-files --quiet --ignore-submodules
if [[ $? -eq 0 ]]; then
COLOR="%{\e[1;32m%}"
else
COLOR="%{\e[1;31m%}"
fi
RPS1="$(print "$COLOR$GIT_BRANCH%{\e[0m%}")"
else
unset RPS1
fi
if [[ -n "$RAW_DATA" ]]; then
set -A DATA ${(s.:::.)RAW_DATA}
LOGIN_PART=${DATA[1]}
STATS_PART=${DATA[2]}