contrib/bash_completion
changeset 2034 5e7aff1b6ae1
parent 1888 283d2ab1e020
child 2035 107dc72880f8
equal deleted inserted replaced
2033:e3280d350792 2034:5e7aff1b6ae1
     1 shopt -s extglob
     1 shopt -s extglob
     2 
       
     3 _hg_option_list()
       
     4 {
       
     5     "$hg" -v help $1 2>/dev/null | \
       
     6 	awk '/^ *-/ {
       
     7 		for (i = 1; i <= NF; i ++) {
       
     8 		    if (index($i, "-") != 1)
       
     9 			break;
       
    10 		    print $i;
       
    11 		}
       
    12 	    }'
       
    13 }
       
    14 
       
    15 
     2 
    16 _hg_commands()
     3 _hg_commands()
    17 {
     4 {
    18     local commands
     5     local commands
    19     commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
     6     commands="$("$hg" debugcomplete "$cur" 2>/dev/null)" || commands=""
    87 	    fi
    74 	    fi
    88 	fi
    75 	fi
    89     done
    76     done
    90 
    77 
    91     if [[ "$cur" == -* ]]; then
    78     if [[ "$cur" == -* ]]; then
    92 	opts=$(_hg_option_list $cmd)
    79 	opts=$("$hg" debugcomplete --options "$cmd" 2>/dev/null)
    93 
    80 
    94 	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
    81 	COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur"))
    95 	return
    82 	return
    96     fi
    83     fi
    97 
    84