Last active
August 29, 2015 14:04
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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