summaryrefslogtreecommitdiff
path: root/zshfunc/vcs-info/vcs_info
diff options
context:
space:
mode:
Diffstat (limited to 'zshfunc/vcs-info/vcs_info')
-rw-r--r--zshfunc/vcs-info/vcs_info68
1 files changed, 68 insertions, 0 deletions
diff --git a/zshfunc/vcs-info/vcs_info b/zshfunc/vcs-info/vcs_info
new file mode 100644
index 0000000..1a90aa6
--- /dev/null
+++ b/zshfunc/vcs-info/vcs_info
@@ -0,0 +1,68 @@
+vcs_info () { # {{{
+ local pat
+ local -i found
+ local -a VCSs disabled dps
+ local -x vcs usercontext
+ local -ix maxexports
+ local -ax msgs
+ local -Ax vcs_comm
+
+ vcs="init"
+ VCSs=(git hg bzr darcs svk mtn svn cvs cdv tla)
+ case $1 in
+ (print_systems_)
+ zstyle -a ":vcs_info:${vcs}:${usercontext}" "disable" disabled
+ print -l '# list of supported version control backends:' \
+ '# disabled systems are prefixed by a hash sign (#)'
+ for vcs in ${VCSs} ; do
+ [[ -n ${(M)disabled:#${vcs}} ]] && printf '#'
+ printf '%s\n' ${vcs}
+ done
+ print -l '# flavours (cannot be used in the disable style; they' \
+ '# are disabled with their master [git-svn -> git]):' \
+ git-{p4,svn}
+ return 0
+ ;;
+ ('')
+ [[ -z ${usercontext} ]] && usercontext=default
+ ;;
+ (*) [[ -z ${usercontext} ]] && usercontext=$1
+ ;;
+ esac
+
+ zstyle -T ":vcs_info:${vcs}:${usercontext}" "enable" || {
+ [[ -n ${VCS_INFO_message_0_} ]] && VCS_INFO_set --clear
+ return 0
+ }
+ zstyle -a ":vcs_info:${vcs}:${usercontext}" "disable" disabled
+
+ zstyle -a ":vcs_info:${vcs}:${usercontext}" "disable-patterns" dps
+ for pat in ${dps} ; do
+ if [[ ${PWD} == ${~pat} ]] ; then
+ [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --clear
+ return 0
+ fi
+ done
+
+ VCS_INFO_maxexports
+
+ (( found = 0 ))
+ for vcs in ${VCSs} ; do
+ [[ -n ${(M)disabled:#${vcs}} ]] && continue
+ vcs_comm=()
+ VCS_INFO_${vcs}_detect && (( found = 1 )) && break
+ done
+
+ (( found == 0 )) && {
+ VCS_INFO_set --nvcs
+ return 0
+ }
+
+ VCS_INFO_${vcs}_get_data || {
+ VCS_INFO_set --nvcs
+ return 1
+ }
+
+ VCS_INFO_set
+ return 0
+}