Reputation: 283043
:vcs_info:
seems to know if you're in a git or hg directory if you enable it:
zstyle ':vcs_info:*' enable git hg
i.e., you can modify your prompt in this way.
How can I tap into that data so that I can write an if
condition? e.g.
if [[ $some_magic_zstyle_vcs_info_variable ]]; then
echo "I'm in a git dir!"
fi
Upvotes: 1
Views: 181
Reputation: 283043
mafredi offered a 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
i.e., the %s
will put the VCS name into $vcs_info_msg_2_
.
Upvotes: 1