fixing line wrap issues with long commands, lost colors

This commit is contained in:
Andrew Davidson 2020-05-20 07:57:27 -04:00
parent e782ee6db5
commit ca54e12e98
Signed by: amd
GPG key ID: 17AF8F2A49CF25C6

View file

@ -5,27 +5,27 @@ autoload -U colors && colors # Enable colors in prompt
function git_branch {
local FULL_BRANCH="$(git symbolic-ref -q HEAD 2>/dev/null || git name-rev --name-only --no-undefined --always HEAD 2>/dev/null)"
local SHORT_BRANCH="$(echo $FULL_BRANCH | sed 's/refs\/heads\///')"
echo " %F{blue}$SHORT_BRANCH%f"
echo "$SHORT_BRANCH"
}
function git_is_ahead {
local NUM_AHEAD="$(git log --oneline @{u}.. 2>/dev/null | wc -l | tr -d ' ')"
if [ "$NUM_AHEAD" -gt 0 ]; then
echo " %F{red}↑%f"
echo ""
fi
}
function git_is_behind {
local NUM_BEHIND="$(git log --oneline ..@{u} 2>/dev/null | wc -l | tr -d ' ' )"
if [ "$NUM_BEHIND" -gt 0 ]; then
echo " %F{blue}↓%f"
echo ""
fi
}
function git_unstaged {
local CHANGED=$(git status --porcelain --ignore-submodule -unormal 2>/dev/null | wc -l)
if [ $CHANGED -gt 0 ]; then
echo -e "%F{yellow}~%f\c"
echo -e "\c"
fi
}
@ -62,4 +62,5 @@ function check_reboot {
test -f /var/run/reboot-required && echo "R "
}
PROMPT='${PR_BOLD_RED}$(check_reboot)${reset_color}%m ${PR_BOLD_YELLOW}$(truncated_pwd 3)$(git_branch)%{$reset_color%}$(git_unstaged)$(git_is_ahead)$(git_is_behind) %(?.%F{magenta}.%F{red})%f '
#PROMPT='${PR_BOLD_RED}$(check_reboot)${reset_color}%m ${PR_BOLD_YELLOW}$(truncated_pwd 3)$(git_branch)%{$reset_color%}$(git_unstaged)$(git_is_ahead)$(git_is_behind) %(?.%F{magenta}.%F{red})%f '
PROMPT='$(check_reboot)%m $(truncated_pwd 3) $(git_branch) $(git_unstaged)$(git_is_ahead)$(git_is_behind)> '