平衡点
2020/11/02
_ zsh の prompt に VCS info を表示する, 2020版
いや, 単に zsh-async に感動したダケなんですけどね.
## VCS info
ps_vcs_info=''
if [[ -n $(echo ${^fpath}/vcs_info(N)) && \
x"$_PR_GIT_UPDATE_" = x"0" ]] ; then
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg svn bzr
zstyle ':vcs_info:*' formats '%s:%b'
zstyle ':vcs_info:*' actionformats '%s:%b|%a'
zstyle ':vcs_info:(svn|bzr)' branchformat '%b:r%r'
zstyle ':vcs_info:bzr:*' use-simple true
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' stagedstr "%B%F{yellow}"
zstyle ':vcs_info:git:*' unstagedstr "%B%F{red}"
zstyle ':vcs_info:git:*' formats '%B%F{green}%c%u%s:%b'
zstyle ':vcs_info:git:*' actionformats '%B%c%u%F{red}%s:%b'
function prompt_vcs_info(){
LANG=C vcs_info "$@"
if [[ -n "$vcs_info_msg_0_" ]]; then
ps_vcs_info="%b%f[$vcs_info_msg_0_%b%f]"
else
ps_vcs_info=''
fi
zle -N reset-prompt
}
precmd_functions+=prompt_vcs_info
source $ZDOTDIR/modules/zsh-async/async.zsh
async_init
async_start_worker vcs_info
async_register_callback vcs_info prompt_vcs_info_done
fi
結構大きなリポジトリでも, 体感動作がかなりサクサクに. これは嬉しい.