1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/python/mach/bash-completion.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,29 @@ 1.4 +function _mach() 1.5 +{ 1.6 + local cur cmds c subcommand 1.7 + COMPREPLY=() 1.8 + 1.9 + # Load the list of commands 1.10 + cmds=`"${COMP_WORDS[0]}" mach-commands` 1.11 + 1.12 + # Look for the subcommand. 1.13 + cur="${COMP_WORDS[COMP_CWORD]}" 1.14 + subcommand="" 1.15 + c=1 1.16 + while [ $c -lt $COMP_CWORD ]; do 1.17 + word="${COMP_WORDS[c]}" 1.18 + for cmd in $cmds; do 1.19 + if [ "$cmd" = "$word" ]; then 1.20 + subcommand="$word" 1.21 + fi 1.22 + done 1.23 + c=$((++c)) 1.24 + done 1.25 + 1.26 + if [[ "$subcommand" == "help" || -z "$subcommand" ]]; then 1.27 + COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) ) 1.28 + fi 1.29 + 1.30 + return 0 1.31 +} 1.32 +complete -o default -F _mach mach