2 # ------------------------------------------------------------------------------
6 # Completion script for git-extras (http://github.com/visionmedia/git-extras).
8 # ------------------------------------------------------------------------------
12 # * Alexis GRIMALDI (https://github.com/agrimaldi)
14 # ------------------------------------------------------------------------------
18 # * git-extras (http://github.com/visionmedia/git-extras)
19 # * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
21 # ------------------------------------------------------------------------------
24 __git_command_successful
() {
25 if (( ${#pipestatus:#0} > 0 )); then
26 _message
'not a git repository'
36 tag_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
37 __git_command_successful
|| return
38 _wanted tag
-names expl tag
-name compadd $
* - $tag_names
42 __git_branch_names
() {
44 declare -a branch_names
45 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
46 __git_command_successful
|| return
47 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
51 __git_feature_branch_names
() {
53 declare -a branch_names
54 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/})
55 __git_command_successful
|| return
56 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
60 __git_refactor_branch_names
() {
62 declare -a branch_names
63 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
64 __git_command_successful
|| return
65 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
69 __git_bug_branch_names
() {
71 declare -a branch_names
72 branch_names
=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
73 __git_command_successful
|| return
74 _wanted branch
-names expl branch
-name compadd $
* - $branch_names
78 __git_submodule_names
() {
80 declare -a submodule_names
81 submodule_names
=(${(f)"$(_call_program branchrefs git submodule status | awk '{print $2}')"})
82 __git_command_successful || return
83 _wanted submodule-names expl submodule-name compadd $* - $submodule_names
87 __git_author_names() {
89 declare -a author_names
90 author_names=(${(f)"$(_call_program branchrefs git log --format='%aN' | sort -u)"})
91 __git_command_successful || return
92 _wanted author-names expl author-name compadd $* - $author_names
98 '(-l --list)'{-l,--list}'[list commits
]' \
104 '--above[ignore
file with
less than x commits
]' \
110 ':author
:__git_author_names
'
116 '--all[detailed commit count
]'
120 _git-delete-branch() {
122 ':branch
-name:__git_branch_names
'
126 _git-delete-submodule() {
128 ':submodule
-name:__git_submodule_names
'
134 ':tag
-name:__git_tag_names
'
139 local curcontext=$curcontext state line ret=1
144 '*:: :->option
-or-argument' && ret=0
150 'update
:update git
-extras'
152 _describe -t commands command commands && ret=0
157 '(-v --version)'{-v,--version}'[show current version
]' \
163 ':src
-branch-name:__git_branch_names
' \
164 ':dest
-branch-name:__git_branch_names
'
170 ':branch
-name:__git_branch_names
'
175 local curcontext=$curcontext state line ret=1
180 '*:: :->option
-or-argument' && ret=0
186 'finish
:merge feature into the current branch
'
188 _describe -t commands command commands && ret=0
191 curcontext=${curcontext%:*}-$line[1]:
195 ':branch
-name:__git_feature_branch_names
'
203 local curcontext=$curcontext state line ret=1
208 '*:: :->option
-or-argument' && ret=0
214 'finish
:merge refactor into the current branch
'
216 _describe -t commands command commands && ret=0
219 curcontext=${curcontext%:*}-$line[1]:
223 ':branch
-name:__git_refactor_branch_names
'
231 local curcontext=$curcontext state line ret=1
236 '*:: :->option
-or-argument' && ret=0
242 'finish
:merge bug into the current branch
'
244 _describe -t commands command commands && ret=0
247 curcontext=${curcontext%:*}-$line[1]:
251 ':branch
-name:__git_bug_branch_names
'
258 zstyle ':completion
:*:*:git
:*' user-commands \
259 changelog:'populate changelog
file with commits since the previous tag
' \
260 contrib:'display author contributions
' \
261 count:'count commits
' \
262 delete-branch:'delete
local and remote branch
' \
263 delete-submodule:'delete submodule
' \
264 delete-tag:'delete
local and remote tag
' \
265 extras:'git
-extras' \
266 graft:'merge commits from
source branch to destination branch
' \
267 squash:'merge commits from
source branch into the current one as a single commit
' \
268 feature:'create a feature branch
' \
269 refactor:'create a refactor branch
' \
270 bug:'create a bug branch
' \
271 summary:'repository summary
' \
272 effort:'display effort statistics
' \
273 repl:'read-eval-print-loop' \
274 commits-since:'list commits since a given
date' \
275 release:'release commit with the given tag
' \
276 alias:'define
, search and show aliases
' \
277 ignore:'add patterns to .gitignore
' \
278 info:'show info about the repository
' \
279 create-branch:'create
local and remote branch
' \
280 fresh-branch:'create empty
local branch
' \
281 undo:'remove the latest commit
' \
282 setup:'setup a git repository
' \
283 touch:'one step creation of new files
' \
284 obliterate:'Completely remove a
file from the repository
, including past commits and tags
' \
285 local-commits:'list unpushed commits on the
local branch
' \