# HG changeset patch # User Alexis S. L. Carvalho # Date 1132729355 -3600 # Node ID 01a5121a005a7efb991ff1d35f9b4ce6cb76896c # Parent 68ec7b9e09a48d8100cf5394279060cefdda1f82 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. diff -r 68ec7b9e09a4 -r 01a5121a005a contrib/bash_completion --- 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()