Show More
@@ -8,9 +8,9 b'' | |||||
8 | # |
|
8 | # | |
9 | # Mercurial allows you to define additional commands through extensions. |
|
9 | # Mercurial allows you to define additional commands through extensions. | |
10 | # Bash should be able to automatically figure out the name of these new |
|
10 | # Bash should be able to automatically figure out the name of these new | |
11 |
# commands and their options. |
|
11 | # commands and their options. See below for how to define _hg_opt_foo | |
12 | # complete non-option arguments, see below for how to define an |
|
12 | # and _hg_cmd_foo functions to fine-tune the completion for option and | |
13 | # _hg_cmd_foo function. |
|
13 | # non-option arguments, respectively. | |
14 | # |
|
14 | # | |
15 | # |
|
15 | # | |
16 | # Notes about completion for specific commands: |
|
16 | # Notes about completion for specific commands: | |
@@ -34,7 +34,10 b'' | |||||
34 | # |
|
34 | # | |
35 | # If it exists, the function _hg_cmd_foo will be called without |
|
35 | # If it exists, the function _hg_cmd_foo will be called without | |
36 | # arguments to generate the completion candidates for the hg command |
|
36 | # arguments to generate the completion candidates for the hg command | |
37 | # "foo". |
|
37 | # "foo". If the command receives some arguments that aren't options | |
|
38 | # even though they start with a "-", you can define a function called | |||
|
39 | # _hg_opt_foo to generate the completion candidates. If _hg_opt_foo | |||
|
40 | # doesn't return 0, regular completion for options is attempted. | |||
38 | # |
|
41 | # | |
39 | # In addition to the regular completion variables provided by bash, |
|
42 | # In addition to the regular completion variables provided by bash, | |
40 | # the following variables are also set: |
|
43 | # the following variables are also set: | |
@@ -109,6 +112,7 b' shopt -s extglob' | |||||
109 | # global options that receive an argument |
|
112 | # global options that receive an argument | |
110 | local global_args='--cwd|-R|--repository' |
|
113 | local global_args='--cwd|-R|--repository' | |
111 | local hg="$1" |
|
114 | local hg="$1" | |
|
115 | local canonical=0 | |||
112 |
|
116 | |||
113 | COMPREPLY=() |
|
117 | COMPREPLY=() | |
114 | cur="$2" |
|
118 | cur="$2" | |
@@ -128,6 +132,10 b' shopt -s extglob' | |||||
128 | done |
|
132 | done | |
129 |
|
133 | |||
130 | if [[ "$cur" == -* ]]; then |
|
134 | if [[ "$cur" == -* ]]; then | |
|
135 | if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then | |||
|
136 | return | |||
|
137 | fi | |||
|
138 | ||||
131 | opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null) |
|
139 | opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null) | |
132 |
|
140 | |||
133 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
|
141 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) | |
@@ -153,7 +161,6 b' shopt -s extglob' | |||||
153 |
|
161 | |||
154 | # try to generate completion candidates for whatever command the user typed |
|
162 | # try to generate completion candidates for whatever command the user typed | |
155 | local help |
|
163 | local help | |
156 | local canonical=0 |
|
|||
157 | if _hg_command_specific; then |
|
164 | if _hg_command_specific; then | |
158 | return |
|
165 | return | |
159 | fi |
|
166 | fi |
General Comments 0
You need to be logged in to leave comments.
Login now