[zsh] A bit of internal prompt cleanup

This commit is contained in:
lara 2020-11-11 04:56:03 +01:00
parent 1f1fa8a5d1
commit a9848d6149

26
prompt
View file

@ -14,9 +14,9 @@ color_username () {
color_prompt_char () {
if [[ $EUID -eq 0 ]]; then
echo "%{$fg_no_bold[red]%}#%{$reset_color%}"
echo "%{$fg_no_bold[red]%G#$reset_color%}"
else
echo "%{$fg_no_bold[blue]%}$%{$reset_color%}"
echo "%{$fg_no_bold[blue]%G\$$reset_color%}"
fi
}
@ -45,7 +45,7 @@ last_status () {
}
virtual_env() {
local prefix="%{$fg_bold[green]%}(%{%b$fg[green]%}"
local prefix="%{$fg_bold[green]%}(%{%b%}"
local suffix="%{$reset_color$fg_bold[green]%})%{$reset_color%}"
[[ -n ${VIRTUAL_ENV} ]] || return
printf '%s' "${prefix}${VIRTUAL_ENV:t}${suffix}"
@ -54,7 +54,7 @@ virtual_env() {
prompt_chars() {
local git_char=''
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
printf '%s' "$(last_status) $(color_prompt_char)"
}
@ -129,25 +129,25 @@ vim_mode () {
# %S - path in the repository
# %a - action (e.g. rebase-i)
# %b - branchname
# %c - stangedstr (see below)
# %c - stagedstr (see below)
# %i - The current revision number or identifier.
# %m - Misc. In case of Git, show information about stashes
# %r - The name of the root directory of the repository
# %s - The current version control system, like git or svn
# %u - unstagedstr (see below)
fmt_branch="%b%{$reset_color%} %u%c%m%{$reset_color%}" # e.g. master¹²
fmt_action="(%{$fg[red]%}%a%{$reset_color%})" # e.g. (rebase-i)
fmt_pre="%{$fg_bold[blue]%}[%{$reset_color%}%{$fg[blue]%}"
fmt_post="%{$fg_bold[blue]%}]%{$reset_color%}"
fmt_branch="%b%{$reset_color%}%u%c%m%{$reset_color%}" # e.g. master¹²
fmt_action="%{$fg[red]%}%a%{$reset_color%}" # e.g. (rebase-i)
fmt_pre="%{$fg_bold[blue]%G[$reset_color$fg[blue]%}"
fmt_post="%{$fg_bold[blue]%G]$reset_color%}"
# check-for-changes can be really slow.
# you should disable it, if you work with large repositories
zstyle ':vcs_info:*' enable git cvs svn
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' unstagedstr "%{$fg_no_bold[yellow]%G●%}"
zstyle ':vcs_info:*' stagedstr "%{$fg_no_bold[green]%}%G●%}"
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:*' stagedstr "%{$fg_no_bold[green]%G●%}"
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:*' nvcsformats ""
zstyle ':vcs_info:*+*:*' debug false # Set to true to see which hooks are being run
zstyle ':vcs_info:git*+set-message:*' hooks git-st git-untracked
@ -215,7 +215,7 @@ prompt_create zle-line-init zle-keymap-select () {
PROMPT+="$(virtual_env)$(prompt_chars) %{$reset_color%}"
# Right prompt with current repo informations
RPROMPT="${vcs_info_msg_0_}%{$reset_color%}%E"
RPROMPT="${vcs_info_msg_0_}%E"
zle reset-prompt
}