git @ Cat's Eye Technologies ellsync / cecc7ab
First pass at bash tab-completion script for ellsync. Chris Pressey 1 year, 6 months ago
1 changed file(s) with 25 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 # To enable tab-completion for ellsync in bash, source this file, like so:
1 # . /path/to/ellsync/script/ellsync_tabcomplete.sh
2 # You might want to do this in your bash startup script.
3
4 function _ellsync_tabcomplete_()
5 {
6 local cmd="${1##*/}"
7 local word=${COMP_WORDS[COMP_CWORD]}
8 local line=${COMP_LINE}
9
10 IFS=' ' read -raargv<<< "$line"
11 local argc=${#argv[@]}
12
13 if [ $argc -eq 2 ]; then
14 COMPREPLY=($(compgen -o default "${word}"))
15 elif [ $argc -eq 3 ]; then
16 COMPREPLY=($(compgen -W "list sync rename" "${word}"))
17 elif [ $argc -gt 3 ]; then
18 local router="${argv[1]}"
19 local streams=`ellsync $router list --stream-name-only`
20 COMPREPLY=($(compgen -W "${streams}" "${word}"))
21 fi
22 }
23
24 complete -F _ellsync_tabcomplete_ ellsync