[zsh] Fix prompt cursor offset

This commit is contained in:
nemirwen 2020-08-04 00:52:13 -04:00
parent 35f835e35c
commit 2df6409303

14
prompt
View file

@ -56,7 +56,7 @@ prompt_chars() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
local git_char="%{$fg_no_bold[blue]%}±%{$reset_color%}" local git_char="%{$fg_no_bold[blue]%}±%{$reset_color%}"
fi fi
printf '%s' "${_GIT_CHAR}$(last_status) $(color_prompt_char)" printf '%s' "$(last_status) $(color_prompt_char)"
} }
charge_batterie() { charge_batterie() {
@ -144,8 +144,8 @@ fmt_post="%{$fg_bold[blue]%}]%{$reset_color%}"
# you should disable it, if you work with large repositories # you should disable it, if you work with large repositories
zstyle ':vcs_info:*' enable git cvs svn zstyle ':vcs_info:*' enable git cvs svn
zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[yellow]%}" zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[yellow]%G●%}"
zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[green]%}" zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[green]%}%G●%}"
zstyle ':vcs_info:*' actionformats "${fmt_pre}${fmt_branch}${fmt_action}${fmt_post} " zstyle ':vcs_info:*' actionformats "${fmt_pre}${fmt_branch}${fmt_action}${fmt_post} "
zstyle ':vcs_info:*' formats "${fmt_pre}${fmt_branch}${fmt_post} " zstyle ':vcs_info:*' formats "${fmt_pre}${fmt_branch}${fmt_post} "
zstyle ':vcs_info:*' nvcsformats "" zstyle ':vcs_info:*' nvcsformats ""
@ -161,7 +161,7 @@ zstyle ':vcs_info:git*+set-message:*' hooks git-st git-untracked
# If instead you want to show the marker only if there are untracked # If instead you want to show the marker only if there are untracked
# files in $PWD, use: # files in $PWD, use:
#[[ -n $(git ls-files --others --exclude-standard) ]] ; then #[[ -n $(git ls-files --others --exclude-standard) ]] ; then
hook_com[unstaged]="%{$fg_no_bold[red]%}●%{$reset_color%}"$hook_com[unstaged] hook_com[unstaged]="%{$fg_no_bold[red]%G●$reset_color%}"$hook_com[unstaged]
fi fi
} }
@ -173,12 +173,12 @@ zstyle ':vcs_info:git*+set-message:*' hooks git-st git-untracked
# for git prior to 1.7 # for git prior to 1.7
# ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l) # ahead=$(git rev-list origin/${hook_com[branch]}..HEAD | wc -l)
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+="%{$fg_no_bold[cyan]%}▴%{$reset_color%}" (( $ahead )) && gitstatus+="%{$fg_no_bold[cyan]%G▴$reset_color%}"
# for git prior to 1.7 # for git prior to 1.7
# behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l) # behind=$(git rev-list HEAD..origin/${hook_com[branch]} | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+="%{$fg_no_bold[magenta]%}▾%{$reset_color%}" (( $behind )) && gitstatus+="%{$fg_no_bold[magenta]%G▾$reset_color%}"
hook_com[misc]+=${gitstatus} hook_com[misc]+=${gitstatus}
} }
@ -209,7 +209,7 @@ prompt_create zle-line-init zle-keymap-select () {
PROMPT+="%{$fg[red]%} $(prompt_msg)" PROMPT+="%{$fg[red]%} $(prompt_msg)"
# Change the background for the whole line and line feed # Change the background for the whole line and line feed
PROMPT+="%{$fg_bold[green]%}%E"$'\n' PROMPT+=$'\n'
# Prompt characters for virtualenv, git and zsh # Prompt characters for virtualenv, git and zsh
PROMPT+="$(virtual_env)$(prompt_chars) %{$reset_color%}" PROMPT+="$(virtual_env)$(prompt_chars) %{$reset_color%}"