##// END OF EJS Templates
bash/zsh completion: use HGPLAIN when invoking hg (issue2297)
Brodie Rao -
r11646:91af149b stable
parent child Browse files
Show More
@@ -54,16 +54,21 b''
54 54
55 55 shopt -s extglob
56 56
57 _hg_cmd()
58 {
59 HGPLAIN=1 "$hg" "$@" 2>/dev/null
60 }
61
57 62 _hg_commands()
58 63 {
59 64 local commands
60 commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
65 commands="$(_hg_cmd debugcomplete "$cur")" || commands=""
61 66 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur"))
62 67 }
63 68
64 69 _hg_paths()
65 70 {
66 local paths="$("$hg" paths 2>/dev/null | sed -e 's/ = .*$//')"
71 local paths="$(_hg_cmd paths | sed -e 's/ = .*$//')"
67 72 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur"))
68 73 }
69 74
@@ -77,21 +82,21 b' shopt -s extglob'
77 82
78 83 _hg_status()
79 84 {
80 local files="$("$hg" status -n$1 . 2>/dev/null)"
85 local files="$(_hg_cmd status -n$1 .)"
81 86 local IFS=$'\n'
82 87 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
83 88 }
84 89
85 90 _hg_tags()
86 91 {
87 local tags="$("$hg" tags -q 2>/dev/null)"
92 local tags="$(_hg_cmd tags -q)"
88 93 local IFS=$'\n'
89 94 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur"))
90 95 }
91 96
92 97 _hg_branches()
93 98 {
94 local branches="$("$hg" branches -q 2>/dev/null)"
99 local branches="$(_hg_cmd branches -q)"
95 100 local IFS=$'\n'
96 101 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur"))
97 102 }
@@ -144,7 +149,7 b' shopt -s extglob'
144 149 return
145 150 fi
146 151
147 opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null)
152 opts=$(_hg_cmd debugcomplete --options "$cmd")
148 153
149 154 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
150 155 return
@@ -175,7 +180,7 b' shopt -s extglob'
175 180 fi
176 181
177 182 # canonicalize the command name and try again
178 help=$("$hg" help "$cmd" 2>/dev/null)
183 help=$(_hg_cmd help "$cmd")
179 184 if [ $? -ne 0 ]; then
180 185 # Probably either the command doesn't exist or it's ambiguous
181 186 return
@@ -272,7 +277,7 b' shopt -s extglob'
272 277 return 0
273 278 }
274 279
275 complete -o bashdefault -o default -F _hg hg 2>/dev/null \
280 complete -o bashdefault -o default -F _hg hg \
276 281 || complete -o default -F _hg hg
277 282
278 283
@@ -281,7 +286,7 b' complete -o bashdefault -o default -F _h'
281 286 # bookmarks
282 287 _hg_bookmarks()
283 288 {
284 local bookmarks="$("$hg" bookmarks --quiet 2>/dev/null )"
289 local bookmarks="$(_hg_cmd bookmarks --quiet )"
285 290 local IFS=$'\n'
286 291 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur"))
287 292 }
@@ -298,7 +303,7 b' complete -o bashdefault -o default -F _h'
298 303 _hg_ext_mq_patchlist()
299 304 {
300 305 local patches
301 patches=$("$hg" $1 2>/dev/null)
306 patches=$(_hg_cmd $1)
302 307 if [ $? -eq 0 ] && [ "$patches" ]; then
303 308 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur"))
304 309 return 0
@@ -308,7 +313,7 b' complete -o bashdefault -o default -F _h'
308 313
309 314 _hg_ext_mq_queues()
310 315 {
311 local root=$("$hg" root 2>/dev/null)
316 local root=$(_hg_cmd root)
312 317 local n
313 318 for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do
314 319 # I think we're usually not interested in the regular "patches" queue
@@ -379,10 +384,9 b' complete -o bashdefault -o default -F _h'
379 384
380 385 _hg_cmd_qcommit()
381 386 {
382 local root=$("$hg" root 2>/dev/null)
387 local root=$(_hg_cmd root)
383 388 # this is run in a sub-shell, so we can't use _hg_status
384 local files=$(cd "$root/.hg/patches" 2>/dev/null &&
385 "$hg" status -nmar 2>/dev/null)
389 local files=$(cd "$root/.hg/patches" && _hg_cmd status -nmar)
386 390 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
387 391 }
388 392
@@ -412,7 +416,7 b' complete -o bashdefault -o default -F _h'
412 416
413 417 _hg_ext_mq_guards()
414 418 {
415 "$hg" qselect --series 2>/dev/null | sed -e 's/^.//'
419 _hg_cmd qselect --series | sed -e 's/^.//'
416 420 }
417 421
418 422 _hg_cmd_qselect()
@@ -557,7 +561,7 b' complete -o bashdefault -o default -F _h'
557 561 # shelve
558 562 _hg_shelves()
559 563 {
560 local shelves="$("$hg" unshelve -l . 2>/dev/null)"
564 local shelves="$(_hg_cmd unshelve -l .)"
561 565 local IFS=$'\n'
562 566 COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur"))
563 567 }
@@ -377,8 +377,7 b' typeset -A _hg_cmd_globals'
377 377 '--remotecmd[specify hg command to run on the remote side]:')
378 378
379 379 _hg_cmd() {
380 _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \
381 "$_hg_cmd_globals[@]" "$@" 2> /dev/null
380 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
382 381 }
383 382
384 383 _hg_cmd_add() {
General Comments 0
You need to be logged in to leave comments. Login now