Skip to content

Instantly share code, notes, and snippets.

@whiteinge
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save whiteinge/c9930a499ade927e6ce5 to your computer and use it in GitHub Desktop.

Select an option

Save whiteinge/c9930a499ade927e6ce5 to your computer and use it in GitHub Desktop.
Example of a hook for vcs_info for optionally displaying the git revision
# Toggle this to test the hook
zstyle ':vcs_info:git:*' get-revision true
# basic 'formats' config: (git)[hash] branch
zstyle ':vcs_info:git*' formats "(%s)%i %b"
# Register new hook
zstyle ':vcs_info:git*+set-message:*' hooks git-optional-rev
# Define new hook
function +vi-git-optional-rev() {
# If revision is a non-empty string, rewrite it with a preceeding space.
if [[ -n "${hook_com[revision]}" ]]; then
hook_com[revision]=" ${hook_com[revision]}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment