bash-completion.sh
branchv_0
changeset 23 d2ad84dcf249
parent 22 eebc16b7c3e4
child 26 a6d332fa816c
equal deleted inserted replaced
22:eebc16b7c3e4 23:d2ad84dcf249
    15 
    15 
    16 _relpipe_out_jack_completion_read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
    16 _relpipe_out_jack_completion_read_nullbyte() { local IFS=; for v in "$@"; do export "$v"; read -r -d '' "$v"; done }
    17 
    17 
    18 _relpipe_out_jack_completion_ports() {
    18 _relpipe_out_jack_completion_ports() {
    19 	if type relpipe-in-jack &> /dev/null && type relpipe-out-nullbyte &> /dev/null; then
    19 	if type relpipe-in-jack &> /dev/null && type relpipe-out-nullbyte &> /dev/null; then
    20 		relpipe-in-jack --list-jack-ports true --list-midi-messages false 2>/dev/null \
    20 		relpipe-in-jack --list-ports true --list-midi-messages false 2>/dev/null \
    21 			| relpipe-out-nullbyte \
    21 			| relpipe-out-nullbyte \
    22 			| while _relpipe_out_jack_completion_read_nullbyte "name" "input" "output" "physical" "terminal" "mine" "midi" "type"; do
    22 			| while _relpipe_out_jack_completion_read_nullbyte "name" "input" "output" "physical" "terminal" "mine" "midi" "type"; do
    23 				 if [[ "$midi" = "true" && "$input" = "true" && "$mine" = "false" ]]; then echo "$name"; fi; done
    23 				 if [[ "$midi" = "true" && "$input" = "true" && "$mine" = "false" ]]; then echo "$name"; fi; done
    24 	fi
    24 	fi
    25 }
    25 }
    31 	w0=${COMP_WORDS[COMP_CWORD]}
    31 	w0=${COMP_WORDS[COMP_CWORD]}
    32 	w1=${COMP_WORDS[COMP_CWORD-1]}
    32 	w1=${COMP_WORDS[COMP_CWORD-1]}
    33 	w2=${COMP_WORDS[COMP_CWORD-2]}
    33 	w2=${COMP_WORDS[COMP_CWORD-2]}
    34 	w3=${COMP_WORDS[COMP_CWORD-3]}
    34 	w3=${COMP_WORDS[COMP_CWORD-3]}
    35 
    35 
    36 	  if [[ "$w1" == "--jack-client-name"             && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-out-jack'")
    36 	  if [[ "$w1" == "--client"                       && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-out-jack'")
    37 	elif [[ "$w1" == "--jack-connect-to-port"                          ]];    then COMPREPLY=($(compgen -W "$(_relpipe_out_jack_completion_ports)" -- "$w0"))
    37 	elif [[ "$w1" == "--port"                         && "x$w0" == "x" ]];    then COMPREPLY=("'midi-out'")
    38 	elif [[ "$w1" == "--required-jack-connections"    && "x$w0" == "x" ]];    then COMPREPLY=("1")
    38 	elif [[ "$w1" == "--connect-to"                                    ]];    then COMPREPLY=($(compgen -W "$(_relpipe_out_jack_completion_ports)" -- "$w0"))
       
    39 	elif [[ "$w1" == "--required-connections"         && "x$w0" == "x" ]];    then COMPREPLY=("1")
    39 	else
    40 	else
    40 		OPTIONS=(
    41 		OPTIONS=(
    41 			"--jack-client-name"
    42 			"--client"
    42 			"--jack-connect-to-port"
    43 			"--port"
    43 			"--required-jack-connections"
    44 			"--connect-to"
       
    45 			"--required-connections"
    44 		)
    46 		)
    45 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    47 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    46 	fi
    48 	fi
    47 }
    49 }
    48 
    50