simplify git prompt

This commit is contained in:
Jason Swank 2025-01-10 14:14:37 +00:00
parent f31d40273c
commit 3970628dac

View File

@ -43,14 +43,22 @@ precmd_functions+=( precmd_vcs_info )
# %r == repo name
# %b == branch name
# %S == relative directory
zstyle ':vcs_info:git*' formats '%%S%r%%s:%{$fg[red]%}%b%{$reset_color%} %S'
zstyle ':vcs_info:git*' formats '%r (%b):%S'
zstyle ':vcs_info:git*' actionformats '%%S%r%%s:%{$fg[red]%}%b:%a%{$reset_color%} %S'
function set_prompt() {
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
PROMPT="%B${vcs_info_msg_0_}> %b"
if [[ -n "$AWS_ENVIRONMENT" ]]; then
aws_prompt="
%S%B$AWS_ENVIRONMENT%b%s
"
else
PROMPT="%B%m:%~> %b"
aws_prompt=""
fi
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
PROMPT=$aws_prompt"%B${vcs_info_msg_0_}> %b"
else
PROMPT=$aws_prompt"%B%m:%~> %b"
fi
}
precmd_functions+=( set_prompt )