1- #! /bin/bash
1+ #! /bin/bash
22
3- # livekit-cli autocomplete for bash
4- # original: https://github.com/urfave/cli/blob/main/autocomplete/bash_autocomplete
3+ # This is a shell completion script auto-generated by https://github.com/urfave/cli for bash.
54
6- _cli_bash_autocomplete () {
5+ # Macs have bash3 for which the bash-completion package doesn't include
6+ # _init_completion. This is a minimal version of that function.
7+ __lk_init_completion () {
8+ COMPREPLY=()
9+ _get_comp_words_by_ref " $@ " cur prev words cword
10+ }
11+
12+ __lk_bash_autocomplete () {
713 if [[ " ${COMP_WORDS[0]} " != " source" ]]; then
8- local cur opts base
14+ local cur opts base words
915 COMPREPLY=()
1016 cur=" ${COMP_WORDS[COMP_CWORD]} "
17+ if declare -F _init_completion > /dev/null 2>&1 ; then
18+ _init_completion -n " =:" || return
19+ else
20+ __lk_init_completion -n " =:" || return
21+ fi
22+ words=(" ${words[@]: 0: $cword } " )
1123 if [[ " $cur " == " -" * ]]; then
12- opts= $( ${COMP_WORDS[@] : 0 : $COMP_CWORD } ${cur} --generate-bash -completion )
24+ requestComp= " ${words[*] } ${cur} --generate-shell -completion"
1325 else
14- opts= $( ${COMP_WORDS[@] : 0 : $COMP_CWORD } --generate-bash -completion )
26+ requestComp= " ${words[*] } --generate-shell -completion"
1527 fi
16- COMPREPLY=( $( compgen -W " ${opts} " -- ${cur} ) )
28+ opts=$( eval " ${requestComp} " 2> /dev/null)
29+ COMPREPLY=($( compgen -W " ${opts} " -- ${cur} ) )
1730 return 0
1831 fi
1932}
2033
21- complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete lk
34+ complete -o bashdefault -o default -o nospace -F __lk_bash_autocomplete lk
0 commit comments