Skip to content

Instantly share code, notes, and snippets.

@forivall
Last active December 26, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save forivall/7090131 to your computer and use it in GitHub Desktop.
Save forivall/7090131 to your computer and use it in GitHub Desktop.
Show git tag rather than just the abbreviated sha1 for vcs_info
# (( ${+functions[vcs_info_hookadd]} )) || autoload -Uz vcs_info_hookadd
# vcs_info_hookadd set-message git-tag-instead-of-sha1
# vcs_info_hookadd doesn't support dynamic hooks. :(
zstyle ':vcs_info:git*+set-message:*' hooks git-tag-instead-of-sha1
+vi-git-tag-instead-of-sha1() {
if [[ ${hook_com[branch]} =~ ^[0-9a-f]+\.{3}$ ]] ; then
local tag=$(git name-rev --name-only --no-undefined --always HEAD)
if (( $? == 0 )) ; then
hook_com[branch]=$tag
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment