1 shopt -s extglob |
1 shopt -s extglob |
2 |
2 |
3 _hg_commands() |
3 _hg_commands() |
4 { |
4 { |
5 local commands="$(hg -v help | sed -e '1,/^list of commands:/d' \ |
5 local all commands result |
6 -e '/^global options:/,$d' \ |
6 |
7 -e '/^ [^ ]/!d; s/[,:]//g;')" |
7 all=($(hg --debug help | sed -e '1,/^list of commands:/d' \ |
|
8 -e '/^global options:/,$d' \ |
|
9 -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;')) |
|
10 |
|
11 commands="${all[*]##debug*}" |
|
12 result=$(compgen -W "${commands[*]}" -- "$cur") |
8 |
13 |
9 # hide debug commands from users, but complete them if |
14 # hide debug commands from users, but complete them if |
10 # specifically asked for |
15 # there is no other possible command |
11 if [[ "$cur" == de* ]]; then |
16 if [ "$result" = "" ]; then |
12 commands="$commands debugcheckstate debugstate debugindex" |
17 local debug |
13 commands="$commands debugindexdot debugwalk debugdata" |
18 debug=(${all[*]##!(debug*)}) |
14 commands="$commands debugancestor debugconfig debugrename" |
19 debug="${debug[*]/g/debug}" |
|
20 result=$(compgen -W "$debug" -- "$cur") |
15 fi |
21 fi |
16 COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cur") ) |
22 |
|
23 COMPREPLY=(${COMPREPLY[@]:-} $result) |
17 } |
24 } |
18 |
25 |
19 _hg_paths() |
26 _hg_paths() |
20 { |
27 { |
21 local paths="$(hg paths | sed -e 's/ = .*$//')" |
28 local paths="$(hg paths | sed -e 's/ = .*$//')" |