mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-02-03 19:30:36 +01:00
shell-completion: fix bash completion if a profile or a port contains spaces
This commit is contained in:
parent
b096704c0d
commit
b517b4398d
1 changed files with 21 additions and 12 deletions
|
|
@ -48,7 +48,7 @@ __ports () {
|
|||
|
||||
flag {
|
||||
if (/^\t\t[A-Za-z]/)
|
||||
ports = ports substr($0, 3, index($0, ":")-3) " "
|
||||
ports = ports substr($0, 3, index($0, ":")-3) "\n"
|
||||
}
|
||||
|
||||
END {
|
||||
|
|
@ -68,7 +68,7 @@ __profiles () {
|
|||
|
||||
flag {
|
||||
if (/^\t\t[A-Za-z]/)
|
||||
profiles = profiles substr($0, 3, index($0, ": ")-3) " "
|
||||
profiles = profiles substr($0, 3, index($0, ": ")-3) "\n"
|
||||
}
|
||||
|
||||
END {
|
||||
|
|
@ -108,6 +108,20 @@ in_array() {
|
|||
done
|
||||
}
|
||||
|
||||
_profiles_helper() {
|
||||
local IFS=$'\n'
|
||||
comps="$(__profiles)"
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$1"))
|
||||
compopt -o fullquote
|
||||
}
|
||||
|
||||
_ports_helper() {
|
||||
local IFS=$'\n'
|
||||
comps="$(__ports)"
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$1"))
|
||||
compopt -o fullquote
|
||||
}
|
||||
|
||||
_pactl() {
|
||||
local cur prev words cword preprev word command
|
||||
local comps
|
||||
|
|
@ -153,13 +167,11 @@ _pactl() {
|
|||
;;
|
||||
|
||||
set-card-profile)
|
||||
comps=$(__profiles)
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
|
||||
_profiles_helper "$cur"
|
||||
;;
|
||||
|
||||
set-*-port)
|
||||
comps=$(__ports)
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
|
||||
_ports_helper "$cur"
|
||||
;;
|
||||
|
||||
set-*-mute) COMPREPLY=($(compgen -W 'true false toggle' -- "$cur")) ;;
|
||||
|
|
@ -168,8 +180,7 @@ _pactl() {
|
|||
;; #TODO
|
||||
|
||||
set-port-*)
|
||||
comps=$(__ports)
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
|
||||
_ports_helper "$cur"
|
||||
;;
|
||||
--server)
|
||||
compopt +o nospace
|
||||
|
|
@ -304,13 +315,11 @@ _pacmd() {
|
|||
;;
|
||||
|
||||
set-card-profile)
|
||||
comps=$(__profiles)
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
|
||||
_profiles_helper "$cur"
|
||||
;;
|
||||
|
||||
set-*port*)
|
||||
comps=$(__ports)
|
||||
COMPREPLY=($(compgen -W '${comps[*]}' -- "$cur"))
|
||||
_ports_helper "$cur"
|
||||
;;
|
||||
|
||||
set-*-mute) COMPREPLY=($(compgen -W 'true false' -- "$cur"));;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue