fix(agnoster): quote % in prompt functions

This commit is contained in:
Marc Cornellà 2021-12-14 11:58:58 +01:00
parent 3e9fe6e772
commit 9836aebe67
No known key found for this signature in database
GPG key ID: 0314585E776A9C1B

View file

@ -135,7 +135,7 @@ prompt_git() {
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
echo -n "${${ref:gs/%/%%}/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi
}
@ -153,7 +153,7 @@ prompt_bzr() {
if bzr_status=$(bzr status 2>&1); then
status_mod=$(echo -n "$bzr_status" | head -n1 | grep "modified" | wc -m)
status_all=$(echo -n "$bzr_status" | head -n1 | wc -m)
revision=$(bzr log -r-1 --log-format line | cut -d: -f1)
revision=${$(bzr log -r-1 --log-format line | cut -d: -f1):gs/%/%%}
if [[ $status_mod -gt 0 ]] ; then
prompt_segment yellow black "bzr@$revision ✚"
else
@ -183,7 +183,7 @@ prompt_hg() {
# if working copy is clean
prompt_segment green $CURRENT_FG
fi
echo -n $(hg prompt "☿ {rev}@{branch}") $st
echo -n ${$(hg prompt "☿ {rev}@{branch}"):gs/%/%%} $st
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
@ -197,7 +197,7 @@ prompt_hg() {
else
prompt_segment green $CURRENT_FG
fi
echo -n "☿ $rev@$branch" $st
echo -n "☿ ${rev:gs/%/%%}@${branch:gs/%/%%}" $st
fi
fi
}
@ -209,9 +209,8 @@ prompt_dir() {
# Virtualenv: current working virtualenv
prompt_virtualenv() {
local virtualenv_path="$VIRTUAL_ENV"
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
prompt_segment blue black "(`basename $virtualenv_path`)"
if [[ -n "$VIRTUAL_ENV" && -n "$VIRTUAL_ENV_DISABLE_PROMPT" ]]; then
prompt_segment blue black "(${VIRTUAL_ENV:t:gs/%/%%})"
fi
}
@ -237,8 +236,8 @@ prompt_status() {
prompt_aws() {
[[ -z "$AWS_PROFILE" || "$SHOW_AWS_PROMPT" = false ]] && return
case "$AWS_PROFILE" in
*-prod|*production*) prompt_segment red yellow "AWS: $AWS_PROFILE" ;;
*) prompt_segment green black "AWS: $AWS_PROFILE" ;;
*-prod|*production*) prompt_segment red yellow "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
*) prompt_segment green black "AWS: ${AWS_PROFILE:gs/%/%%}" ;;
esac
}