Show More
@@ -84,7 +84,6 b' shopt -s extglob' | |||||
84 | { |
|
84 | { | |
85 | local files="$(_hg_cmd debugpathcomplete $1 "$cur")" |
|
85 | local files="$(_hg_cmd debugpathcomplete $1 "$cur")" | |
86 | local IFS=$'\n' |
|
86 | local IFS=$'\n' | |
87 | compopt -o filenames 2>/dev/null |
|
|||
88 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
|
87 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) | |
89 | } |
|
88 | } | |
90 |
|
89 | |||
@@ -92,7 +91,6 b' shopt -s extglob' | |||||
92 | { |
|
91 | { | |
93 | local files="$(_hg_cmd status -n$1 "glob:$cur**")" |
|
92 | local files="$(_hg_cmd status -n$1 "glob:$cur**")" | |
94 | local IFS=$'\n' |
|
93 | local IFS=$'\n' | |
95 | compopt -o filenames 2>/dev/null |
|
|||
96 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
|
94 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) | |
97 | } |
|
95 | } | |
98 |
|
96 | |||
@@ -128,6 +126,19 b' shopt -s extglob' | |||||
128 | echo $(($count - 1)) |
|
126 | echo $(($count - 1)) | |
129 | } |
|
127 | } | |
130 |
|
128 | |||
|
129 | _hg_fix_wordlist() | |||
|
130 | { | |||
|
131 | local LASTCHAR=' ' | |||
|
132 | if [ ${#COMPREPLY[@]} = 1 ]; then | |||
|
133 | [ -d "$COMPREPLY" ] && LASTCHAR=/ | |||
|
134 | COMPREPLY=$(printf %q%s "$COMPREPLY" "$LASTCHAR") | |||
|
135 | else | |||
|
136 | for ((i=0; i < ${#COMPREPLY[@]}; i++)); do | |||
|
137 | [ -d "${COMPREPLY[$i]}" ] && COMPREPLY[$i]=${COMPREPLY[$i]}/ | |||
|
138 | done | |||
|
139 | fi | |||
|
140 | } | |||
|
141 | ||||
131 | _hg() |
|
142 | _hg() | |
132 | { |
|
143 | { | |
133 | local cur prev cmd cmd_index opts i aliashg |
|
144 | local cur prev cmd cmd_index opts i aliashg | |
@@ -162,12 +173,14 b' shopt -s extglob' | |||||
162 |
|
173 | |||
163 | if [[ "$cur" == -* ]]; then |
|
174 | if [[ "$cur" == -* ]]; then | |
164 | if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then |
|
175 | if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then | |
|
176 | _hg_fix_wordlist | |||
165 | return |
|
177 | return | |
166 | fi |
|
178 | fi | |
167 |
|
179 | |||
168 | opts=$(_hg_cmd debugcomplete --options "$cmd") |
|
180 | opts=$(_hg_cmd debugcomplete --options "$cmd") | |
169 |
|
181 | |||
170 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
|
182 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) | |
|
183 | _hg_fix_wordlist | |||
171 | return |
|
184 | return | |
172 | fi |
|
185 | fi | |
173 |
|
186 | |||
@@ -176,22 +189,26 b' shopt -s extglob' | |||||
176 | -R|--repository) |
|
189 | -R|--repository) | |
177 | _hg_paths |
|
190 | _hg_paths | |
178 | _hg_repos |
|
191 | _hg_repos | |
|
192 | _hg_fix_wordlist | |||
179 | return |
|
193 | return | |
180 | ;; |
|
194 | ;; | |
181 | --cwd) |
|
195 | --cwd) | |
182 | # Stick with default bash completion |
|
196 | # Stick with default bash completion | |
|
197 | _hg_fix_wordlist | |||
183 |
|
|
198 | return | |
184 | ;; |
|
199 | ;; | |
185 | esac |
|
200 | esac | |
186 |
|
201 | |||
187 | if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then |
|
202 | if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then | |
188 | _hg_commands |
|
203 | _hg_commands | |
|
204 | _hg_fix_wordlist | |||
189 | return |
|
205 | return | |
190 | fi |
|
206 | fi | |
191 |
|
207 | |||
192 | # try to generate completion candidates for whatever command the user typed |
|
208 | # try to generate completion candidates for whatever command the user typed | |
193 | local help |
|
209 | local help | |
194 | if _hg_command_specific; then |
|
210 | if _hg_command_specific; then | |
|
211 | _hg_fix_wordlist | |||
195 | return |
|
212 | return | |
196 | fi |
|
213 | fi | |
197 |
|
214 | |||
@@ -205,6 +222,7 b' shopt -s extglob' | |||||
205 | cmd=${cmd%%[$' \n']*} |
|
222 | cmd=${cmd%%[$' \n']*} | |
206 | canonical=1 |
|
223 | canonical=1 | |
207 | _hg_command_specific |
|
224 | _hg_command_specific | |
|
225 | _hg_fix_wordlist | |||
208 | } |
|
226 | } | |
209 |
|
227 | |||
210 | _hg_command_specific() |
|
228 | _hg_command_specific() | |
@@ -291,8 +309,8 b' shopt -s extglob' | |||||
291 | return 0 |
|
309 | return 0 | |
292 | } |
|
310 | } | |
293 |
|
311 | |||
294 | complete -o bashdefault -o default -F _hg hg \ |
|
312 | complete -o bashdefault -o default -o nospace -F _hg hg \ | |
295 | || complete -o default -F _hg hg |
|
313 | || complete -o default -o nospace -F _hg hg | |
296 |
|
314 | |||
297 |
|
315 | |||
298 | # Completion for commands provided by extensions |
|
316 | # Completion for commands provided by extensions |
General Comments 0
You need to be logged in to leave comments.
Login now