平衡点


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

結構大きなリポジトリでも, 体感動作がかなりサクサクに. これは嬉しい.


連絡先など
最近の日記
一覧
2006|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|02|03|04|08|09|10|11|12|
2013|01|02|03|04|05|06|08|09|10|11|12|
2014|01|02|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|09|10|
2016|02|03|
2017|01|02|03|05|06|07|09|11|12|
2018|03|06|07|10|11|12|
2019|01|02|03|04|05|07|10|12|
2020|01|02|03|04|05|08|09|10|11|12|
2021|01|02|03|05|06|07|08|09|11|12|
2022|01|02|03|04|05|06|08|10|11|12|
2023|02|03|04|06|08|09|11|12|
2024|01|02|03|
Back to Top ▲