6 # To achieve git-flow 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-flow-completion.zsh) and put the following line in
18 # source ~/.git-flow-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 'version:Shows version information.'
44 _describe
-t commands
'git flow' subcommands
52 -f'[Force setting of gitflow branches, even if already configured]'
76 local curcontext
="$curcontext" state line
80 ':command:->command' \
81 '*::options:->options'
88 'start:Start a new release branch.'
89 'finish:Finish a release branch.'
90 'list:List all your release branches. (Alias to `git flow release`)'
92 _describe
-t commands
'git flow release' subcommands
94 -v'[Verbose (more) output]'
102 -F'[Fetch from origin before performing finish]'\
103 ':version:__git_flow_version_list'
108 -F'[Fetch from origin before performing finish]' \
109 -s'[Sign the release tag cryptographically]'\
110 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
111 -m'[Use the given tag message]'\
112 -p'[Push to $ORIGIN after performing finish]'\
113 -k'[Keep branch after performing finish]'\
114 -n"[Don't tag this release]"\
115 ':version:__git_flow_version_list'
120 -v'[Verbose (more) output]'
129 local curcontext
="$curcontext" state line
133 ':command:->command' \
134 '*::options:->options'
141 'start:Start a new hotfix branch.'
142 'finish:Finish a hotfix branch.'
143 'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
145 _describe
-t commands
'git flow hotfix' subcommands
147 -v'[Verbose (more) output]'
155 -F'[Fetch from origin before performing finish]'\
156 ':hotfix:__git_flow_version_list'\
157 ':branch-name:__git_branch_names'
162 -F'[Fetch from origin before performing finish]' \
163 -s'[Sign the release tag cryptographically]'\
164 -u'[Use the given GPG-key for the digital signature (implies -s)]'\
165 -m'[Use the given tag message]'\
166 -p'[Push to $ORIGIN after performing finish]'\
167 -k'[Keep branch after performing finish]'\
168 -n"[Don't tag this release]"\
169 ':hotfix:__git_flow_hotfix_list'
174 -v'[Verbose (more) output]'
181 __git
-flow-feature ()
183 local curcontext
="$curcontext" state line
187 ':command:->command' \
188 '*::options:->options'
195 'start:Start a new feature branch.'
196 'finish:Finish a feature branch.'
197 'list:List all your feature branches. (Alias to `git flow feature`)'
205 _describe
-t commands
'git flow feature' subcommands
207 -v'[Verbose (more) output]'
215 -F'[Fetch from origin before performing finish]'\
216 ':feature:__git_flow_feature_list'\
217 ':branch-name:__git_branch_names'
222 -F'[Fetch from origin before performing finish]' \
223 -r'[Rebase instead of merge]'\
224 -k'[Keep branch after performing finish]'\
225 ':feature:__git_flow_feature_list'
230 ':feature:__git_flow_feature_list'\
235 ':feature:__git_flow_feature_list'\
240 ':branch:__git_branch_names'\
245 -i'[Do an interactive rebase]' \
246 ':branch:__git_branch_names'
251 ':branch:__git_flow_feature_list'\
256 ':remote:__git_remotes'\
257 ':branch:__git_branch_names'
262 -v'[Verbose (more) output]'
269 __git_flow_version_list
()
274 versions
=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
275 __git_command_successful
|| return
277 _wanted versions expl
'version' compadd
$versions
280 __git_flow_feature_list
()
285 features
=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
286 __git_command_successful
|| return
288 _wanted features expl
'feature' compadd
$features
292 local expl gitdir remotes
294 gitdir
=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
295 __git_command_successful
|| return
297 remotes
=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
298 __git_command_successful
|| return
300 # TODO: Should combine the two instead of either or.
301 if (( $#remotes > 0 )); then
302 _wanted remotes expl remote compadd $
* - $remotes
304 _wanted remotes expl remote _files $
* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
308 __git_flow_hotfix_list
()
313 hotfixes
=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
314 __git_command_successful
|| return
316 _wanted hotfixes expl
'hotfix' compadd
$hotfixes
319 __git_branch_names
() {
321 declare -a branch_names
323 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
324 __git_command_successful
|| return
326 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
329 __git_command_successful
() {
330 if (( ${#pipestatus:#0} > 0 )); then
331 _message
'not a git repository'
337 zstyle
':completion:*:*:git:*' user
-commands flow
:'description for foo'