Move VCS function in prompt

This commit is contained in:
tastytea 2022-04-24 19:35:03 +02:00
parent cff0899edb
commit 69c528842a
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -51,24 +51,6 @@ function prompt_tastytea_shrunkpwd() {
print -n ${out} print -n ${out}
} }
function prompt_tastytea_vcs() {
autoload -U vcs_info
zmodload zsh/zutil
zstyle ':vcs_info:*' formats "%F{${prompt_tastytea_colours[vcs]}}(%b)%u%c%f "
zstyle ':vcs_info:*' actionformats "%F{${prompt_tastytea_colours[vcs]}}(%b|%F{${prompt_tastytea_colours[highlight]}}%a%F{${prompt_tastytea_colours[vcs]}})%u%c%f "
zstyle ':vcs_info:*' stagedstr "%F{${prompt_tastytea_colours[highlight]}}●"
zstyle ':vcs_info:*' unstagedstr "%F{${prompt_tastytea_colours[highlight]}}○"
# Use asynchronous VCS prompt if zsh-async is available
if [[ -v ASYNC_VERSION ]]; then
[[ ${ASYNC_INIT_DONE} -eq 0 ]] && async_init
prompt_tastytea_vcs_async
else
add-zsh-hook precmd vcs_info
fi
}
# Needs <https://github.com/mafredri/zsh-async> # Needs <https://github.com/mafredri/zsh-async>
function prompt_tastytea_vcs_async() { function prompt_tastytea_vcs_async() {
# From https://vincent.bernat.ch/en/blog/2019-zsh-async-vcs-info # From https://vincent.bernat.ch/en/blog/2019-zsh-async-vcs-info
@ -113,6 +95,24 @@ function prompt_tastytea_vcs_async() {
add-zsh-hook chpwd prompt_tastytea_vcs_chpwd add-zsh-hook chpwd prompt_tastytea_vcs_chpwd
} }
function prompt_tastytea_vcs() {
autoload -U vcs_info
zmodload zsh/zutil
zstyle ':vcs_info:*' formats "%F{${prompt_tastytea_colours[vcs]}}(%b)%u%c%f "
zstyle ':vcs_info:*' actionformats "%F{${prompt_tastytea_colours[vcs]}}(%b|%F{${prompt_tastytea_colours[highlight]}}%a%F{${prompt_tastytea_colours[vcs]}})%u%c%f "
zstyle ':vcs_info:*' stagedstr "%F{${prompt_tastytea_colours[highlight]}}●"
zstyle ':vcs_info:*' unstagedstr "%F{${prompt_tastytea_colours[highlight]}}○"
# Use asynchronous VCS prompt if zsh-async is available
if [[ -v ASYNC_VERSION ]]; then
[[ ${ASYNC_INIT_DONE} -eq 0 ]] && async_init
prompt_tastytea_vcs_async
else
add-zsh-hook precmd vcs_info
fi
}
function prompt_tastytea_setup() { function prompt_tastytea_setup() {
if [[ ${ZSH_VERSION[1]} -lt 5 ]]; then if [[ ${ZSH_VERSION[1]} -lt 5 ]]; then
print -u2 "This theme needs Zsh >= 5" print -u2 "This theme needs Zsh >= 5"