:vcs_info:
似乎知道您是否在git或hg目录中:
zstyle ':vcs_info:*' enable git hg
即,您可以通过这种方式修改提示。
如何点击该数据以便我可以写出if
条件? e.g。
if [[ $some_magic_zstyle_vcs_info_variable ]]; then
echo "I'm in a git dir!"
fi
答案 0 :(得分:1)
mafredi提供better solution:
zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:*' max-exports 3
zstyle ':vcs_info:(git|hg):*' formats ' %b' 'x%R' '%s'
zstyle ':vcs_info:(git|hg):*' actionformats ' %b|%a' 'x%R' '%s'
...
if [[ "$vcs_info_msg_2_" == "git" ]]; then
# git
fi
if [[ "$vcs_info_msg_2_" == "hg" ]]; then
# hg
fi
即,%s
会将VCS名称放入$vcs_info_msg_2_
。