Mercurial > hg-stable
comparison contrib/bash_completion @ 1555:01a5121a005a
bash_completion: use hg --debug help to get the list of debug commands.
Also, try completing with the debug commands only when there's no other
candidates.
Based on an idea by TK Soh.
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Wed, 23 Nov 2005 08:02:35 +0100 |
parents | f351d1a07d75 |
children | 561b17b7d3a2 |
comparison
equal
deleted
inserted
replaced
1554:68ec7b9e09a4 | 1555:01a5121a005a |
---|---|
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/ = .*$//')" |