6 # To achieve git-hubflow completion nirvana:
8 # 0. Update your zsh's git-completion module to the newest verion.
9 # From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD
11 # 1. Install this file. Either:
13 # a. Place it in your .zshrc:
15 # b. Or, copy it somewhere (e.g. ~/.git-hubflow-completion.zsh) and put the following line in
18 # source ~/.git-hubflow-completion.zsh
20 # c. Or, use this file as a oh-my-zsh plugin.
25 local curcontext
="$curcontext" state line
29 ':command:->command' \
30 '*::options:->options'
37 'init:Initialize a new git repo with support for the branching model.'
38 'feature:Manage your feature branches.'
39 'release:Manage your release branches.'
40 'hotfix:Manage your hotfix branches.'
41 'support:Manage your support branches.'
42 'update:Pull upstream changes down into your master and develop branches.'
43 'version:Shows version information.'
45 _describe
-t commands
'git hf' subcommands
53 -f'[Force setting of gitflow branches, even if already configured]'
77 local curcontext
="$curcontext" state line
81 ':command:->command' \
82 '*::options:->options'
89 'start:Start a new release branch.'
90 'finish:Finish a release branch.'
91 'list:List all your release branches. (Alias to `git hf release`)'
92 'cancel:Cancel release'
93 'push:Push release to github'
94 'pull:Pull release from github'
97 _describe
-t commands
'git hf release' subcommands
99 -v'[Verbose (more) output]'
107 -F'[Fetch from origin before performing finish]'\
108 ':version:__git_hf_version_list'
113 -F'[Fetch from origin before performing finish]' \
114 -s'[Sign the release tag cryptographically]'\
115 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
116 -m'[Use the given tag message]'\
117 -p'[Push to $ORIGIN after performing finish]'\
118 -k'[Keep branch after performing finish]'\
119 -n"[Don't tag this release]"\
120 ':version:__git_hf_version_list'
125 -v'[Verbose (more) output]'
134 local curcontext
="$curcontext" state line
138 ':command:->command' \
139 '*::options:->options'
146 'start:Start a new hotfix branch.'
147 'finish:Finish a hotfix branch.'
148 'list:List all your hotfix branches. (Alias to `git hf hotfix`)'
149 'publish:Publish the hotfix branch.'
150 'track:Track the hotfix branch.'
151 'pull:Pull the hotfix from github.'
152 'push:Push the hotfix to github.'
153 'cancel:Cancel the hotfix.'
155 _describe
-t commands
'git hf hotfix' subcommands
157 -v'[Verbose (more) output]'
165 -F'[Fetch from origin before performing finish]'\
166 ':hotfix:__git_hf_version_list'\
167 ':branch-name:__git_branch_names'
172 -F'[Fetch from origin before performing finish]' \
173 -s'[Sign the release tag cryptographically]'\
174 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
175 -m'[Use the given tag message]'\
176 -p'[Push to $ORIGIN after performing finish]'\
177 -k'[Keep branch after performing finish]'\
178 -n"[Don't tag this release]"\
179 ':hotfix:__git_hf_hotfix_list'
184 -v'[Verbose (more) output]'
193 local curcontext
="$curcontext" state line
197 ':command:->command' \
198 '*::options:->options'
205 'list:List all your feature branches. (Alias to `git hf feature`)'
206 'start:Start a new feature branch'
207 'finish:Finish a feature branch'
211 'rebase:Rebase feature branch against develop'
212 'checkout:Checkout feature'
213 'pull:Pull feature branch from github'
214 'push:Push feature branch to github'
215 'cancel:Cancel feature'
217 _describe
-t commands
'git hf feature' subcommands
219 -v'[Verbose (more) output]'
227 -F'[Fetch from origin before performing finish]'\
228 ':feature:__git_hf_feature_list'\
229 ':branch-name:__git_branch_names'
234 -F'[Fetch from origin before performing finish]' \
235 -r'[Rebase instead of merge]'\
236 ':feature:__git_hf_feature_list'
241 ':feature:__git_hf_feature_list'\
246 ':feature:__git_hf_feature_list'\
251 ':branch:__git_branch_names'\
256 -i'[Do an interactive rebase]' \
257 ':branch:__git_branch_names'
262 ':branch:__git_hf_feature_list'\
267 ':remote:__git_remotes'\
268 ':branch:__git_branch_names'
273 -v'[Verbose (more) output]'
280 __git_hf_version_list
()
285 versions
=(${${(f)"$(_call_program versions git hf release list 2> /dev/null | tr -d ' |*')"}})
286 __git_command_successful
|| return
288 _wanted versions expl
'version' compadd
$versions
291 __git_hf_feature_list
()
296 features
=(${${(f)"$(_call_program features git hf feature list 2> /dev/null | tr -d ' |*')"}})
297 __git_command_successful
|| return
299 _wanted features expl
'feature' compadd
$features
303 local expl gitdir remotes
305 gitdir
=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
306 __git_command_successful
|| return
308 remotes
=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
309 __git_command_successful
|| return
311 # TODO: Should combine the two instead of either or.
312 if (( $#remotes > 0 )); then
313 _wanted remotes expl remote compadd $
* - $remotes
315 _wanted remotes expl remote _files $
* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
319 __git_hf_hotfix_list
()
324 hotfixes
=(${${(f)"$(_call_program hotfixes git hf hotfix list 2> /dev/null | tr -d ' |*')"}})
325 __git_command_successful
|| return
327 _wanted hotfixes expl
'hotfix' compadd
$hotfixes
330 __git_branch_names
() {
332 declare -a branch_names
334 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
335 __git_command_successful
|| return
337 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
340 __git_command_successful
() {
341 if (( ${#pipestatus:#0} > 0 )); then
342 _message
'not a git repository'
348 zstyle
':completion:*:*:git:*' user
-commands flow
:'description for foo'