Merge pull request #1385 from davvid/bindir
[git-cola.git] / contrib / git-cola-completion.bash
blob6c6cba855e1a8616aa79b3ac385ac0c66a88a439
1 # git-cola extensions for Git's git-completion.bash script
3 # This script must be sourced *after* Git's git-completion.bash script.
4 # Source git.git's git-completion.bash and then source this script from
5 # your ~/.bashrc in order to activate the completions.
7 # Completion is provided for "git cola ..." and "git dag ..." via the
8 # _git_cola() and _git_dag() functions.
9 # See git.git's contrib/completion/git-completion.bash for more details.
11 __git_cola_common_options="--icon-theme --prompt --repo --theme --version"
12 __git_cola_subcommands_list=
14 __git_cola_common_opts () {
15 __gitcomp "$__git_cola_common_options $1"
18 _git_cola () {
19 __git_has_doubledash && return
21 if test -z "$__git_cola_subcommands_list"
22 then
23 __git_cola_subcommands_list=$(
24 git cola --help-commands |
25 grep '^ [a-z]' |
26 grep -v cola |
27 cut -d' ' -f5)
30 local subcommand=$(__git_find_on_cmdline "$__git_cola_subcommands_list")
32 case "$prev" in
33 --repo)
34 return
36 esac
38 if test -z "$subcommand"
39 then
40 __gitcomp "
41 $__git_cola_subcommands_list
42 $__git_cola_common_options
43 --amend
44 --help-commands
45 --status-filter
47 return
50 case "$subcommand" in
51 am)
52 return
54 dag)
55 _git_dag "$@"
56 return
58 archive|diff|merge)
59 __git_complete_revlist
60 __git_cola_common_opts
62 grep)
63 # do nothing
65 pull)
66 __git_cola_common_opts --rebase
68 rebase)
69 case "$prev" in
70 --exec)
71 return
73 --whitespace)
74 __gitcomp "nowarn warn fix error error-all"
75 return
77 --strategy)
78 __gitcomp "resolve recursive octopus ours subtree"
79 return
81 --strategy-option)
82 __gitcomp "ours theirs patience
83 diff-algorithm=patience
84 diff-algorithm=minimal
85 diff-algorithm=histogram
86 diff-algorithm=myers
87 ignore-all-space
88 ignore-space-at-eol
89 ignore-space-change
90 renormalize
91 no-renormalize
92 rename-threshold=
93 subtree=
95 return
97 esac
99 __git_complete_revlist
100 __git_cola_common_opts "
101 --abort
102 --autostash
103 --autosquash
104 --committer-date-is-author-date
105 --continue
106 --ignore-date
107 --ignore-whitespace
108 --edit-todo
109 --exec
110 --force-rebase
111 --fork-point
112 --merge
113 --no-autosquash
114 --no-ff
115 --no-stat
116 --onto
117 --preserve-merges
118 --quiet
119 --rerere-autoupdate
120 --root
121 --skip
122 --stat
123 --stop
124 --strategy
125 --strategy-option
126 --update-refs
127 --verbose
128 --verify
129 --whitespace
132 tag)
133 case "$cword" in
135 # do nothing
138 __git_complete_revlist
140 esac
143 __git_cola_common_opts
145 esac
148 _git_dag () {
149 __git_has_doubledash && return
151 if test "$prev" = "--max-count"
152 then
153 return
155 __git_cola_common_opts --max-count
156 __git_complete_revlist