python/mach/bash-completion.sh

branch
TOR_BUG_9701
changeset 3
141e0f1194b1
equal deleted inserted replaced
-1:000000000000 0:1dab383c09b3
1 function _mach()
2 {
3 local cur cmds c subcommand
4 COMPREPLY=()
5
6 # Load the list of commands
7 cmds=`"${COMP_WORDS[0]}" mach-commands`
8
9 # Look for the subcommand.
10 cur="${COMP_WORDS[COMP_CWORD]}"
11 subcommand=""
12 c=1
13 while [ $c -lt $COMP_CWORD ]; do
14 word="${COMP_WORDS[c]}"
15 for cmd in $cmds; do
16 if [ "$cmd" = "$word" ]; then
17 subcommand="$word"
18 fi
19 done
20 c=$((++c))
21 done
22
23 if [[ "$subcommand" == "help" || -z "$subcommand" ]]; then
24 COMPREPLY=( $(compgen -W "$cmds" -- ${cur}) )
25 fi
26
27 return 0
28 }
29 complete -o default -F _mach mach

mercurial