|
|
@ -41,7 +41,6 @@ prompt_context() { |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
# TODO: remove `grep` commands |
|
|
|
|
|
|
|
prompt_git() { |
|
|
|
prompt_git() { |
|
|
|
if ! command -pv git > /dev/null 2>&1; then |
|
|
|
if ! command -pv git > /dev/null 2>&1; then |
|
|
|
return |
|
|
|
return |
|
|
@ -50,16 +49,29 @@ prompt_git() { |
|
|
|
repo_path="$(git rev-parse --git-dir 2> /dev/null)" |
|
|
|
repo_path="$(git rev-parse --git-dir 2> /dev/null)" |
|
|
|
if [ -n "$repo_path" ]; then |
|
|
|
if [ -n "$repo_path" ]; then |
|
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" |
|
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" |
|
|
|
git_status="$(git status --porcelain --ignore-submodules=dirty 2> /dev/null)" |
|
|
|
git_status="$(git status --porcelain=v1 --ignore-submodules=dirty 2> /dev/null)" |
|
|
|
git_str="" |
|
|
|
git_str="" |
|
|
|
if [ -n "$git_status" ]; then |
|
|
|
if [ -n "$git_status" ]; then |
|
|
|
prompt_segment "$SEGMENT_SEPARATOR" yellow black |
|
|
|
prompt_segment "$SEGMENT_SEPARATOR" yellow black |
|
|
|
if [ -n "$(printf "%s" "$git_status" | grep -e "^[MADRCU? ][MADRCU?]")" ]; then |
|
|
|
# Using `emulate` here is ugly as hell, but necessary to not get syntax |
|
|
|
git_str="$git_str±" # Unstaged |
|
|
|
# error from `sh/dash`. Hope it doesn't costs too much in performances. |
|
|
|
fi |
|
|
|
[ -z ${ZSH_VERSION+x} ] && emulate zsh -c 'git_status=( ${(f)"${git_Status}"} )' |
|
|
|
if [ -n "$(printf "%s" "$git_status" | grep -e "^[MADRCU]")" ]; then |
|
|
|
OLDIFS="$IFS" |
|
|
|
git_str="$git_str✚" # Staged |
|
|
|
IFS=" |
|
|
|
fi |
|
|
|
" |
|
|
|
|
|
|
|
for line in $git_status; do |
|
|
|
|
|
|
|
git_states="${line%%"${line##[MTADRCU?! ][MTADRCU?! ]}"}" |
|
|
|
|
|
|
|
if [ -z ${git_staged+x} ] && [ -n "${git_states##["?""!"" "][MTADRCU?! ]}" ]; then |
|
|
|
|
|
|
|
git_staged="✚" # Staged |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
if [ -z ${git_dirty+x} ] && [ -n "${git_states##[MTADRCU?! ]["!"" "]}" ]; then |
|
|
|
|
|
|
|
git_dirty="±" # Unstaged (Dirty tree) |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
[ -z ${git_staged+x} ] || [ -z ${git_dirty+x} ] || break |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
IFS="$OLDIFS" |
|
|
|
|
|
|
|
git_str="$git_dirty$git_staged" |
|
|
|
|
|
|
|
unset git_states git_staged git_dirty OLDIFS |
|
|
|
else |
|
|
|
else |
|
|
|
prompt_segment "$SEGMENT_SEPARATOR" green black |
|
|
|
prompt_segment "$SEGMENT_SEPARATOR" green black |
|
|
|
fi |
|
|
|
fi |
|
|
@ -110,7 +122,7 @@ build_prompt() { |
|
|
|
unset OLD_BG OLD_SEP |
|
|
|
unset OLD_BG OLD_SEP |
|
|
|
printf "%s%s " "%{%f%b%k%}" "$PROMPT_LINE" |
|
|
|
printf "%s%s " "%{%f%b%k%}" "$PROMPT_LINE" |
|
|
|
unset PROMPT_LINE |
|
|
|
unset PROMPT_LINE |
|
|
|
unset -f prompt_segment prompt_status prompt_virtualenv prompt_context prompt_git |
|
|
|
unset -f prompt_segment prompt_status prompt_virtualenv prompt_context prompt_git get_apid |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setopt prompt_subst |
|
|
|
setopt prompt_subst |
|
|
|