Mercurial > hg-stable
changeset 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 | 68ec7b9e09a4 |
children | 561b17b7d3a2 |
files | contrib/bash_completion |
diffstat | 1 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/contrib/bash_completion Thu Nov 17 19:38:57 2005 +0100 +++ b/contrib/bash_completion Wed Nov 23 08:02:35 2005 +0100 @@ -2,18 +2,25 @@ _hg_commands() { - local commands="$(hg -v help | sed -e '1,/^list of commands:/d' \ - -e '/^global options:/,$d' \ - -e '/^ [^ ]/!d; s/[,:]//g;')" + local all commands result + + all=($(hg --debug help | sed -e '1,/^list of commands:/d' \ + -e '/^global options:/,$d' \ + -e '/^ [^ ]/!d; s/^ //; s/[,:]//g;')) + + commands="${all[*]##debug*}" + result=$(compgen -W "${commands[*]}" -- "$cur") # hide debug commands from users, but complete them if - # specifically asked for - if [[ "$cur" == de* ]]; then - commands="$commands debugcheckstate debugstate debugindex" - commands="$commands debugindexdot debugwalk debugdata" - commands="$commands debugancestor debugconfig debugrename" + # there is no other possible command + if [ "$result" = "" ]; then + local debug + debug=(${all[*]##!(debug*)}) + debug="${debug[*]/g/debug}" + result=$(compgen -W "$debug" -- "$cur") fi - COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -W "$commands" -- "$cur") ) + + COMPREPLY=(${COMPREPLY[@]:-} $result) } _hg_paths()