completions/pactl: Fix matching objects

This didn't work for something like `pactl set-card-profile foo
<TAB>`,
because it didn't allow for the card name, as it would just print the
index again and again.
This commit is contained in:
Fabian Boehm 2023-07-19 18:07:03 +02:00
parent 2a16e3513e
commit 5f26c56ed5

View File

@ -18,15 +18,15 @@ else
end end
function __fish_pa_complete_type function __fish_pa_complete_type
pactl list short $argv # Print a completion candidate for the object type (like "card" or "sink"),
# The default is to show the number, then the name and then some info - also show the name, then the number as it's a bit friendlier # with a description.
pactl list short $argv | string replace -r '(\w+)\t([-\w]+)' '$2\t$1' # Pa allows both a numerical index and a name
pactl list short $argv | string replace -rf '(\d+)\s+(\S+)(\s+.*)?' '$2\t$1$3\n$1\t$2$3'
end end
function __fish_pa_print_type function __fish_pa_print_type
pactl list short $argv # Print just the object, without description
# Pa allows both a numerical index and a name __fish_pa_complete_type $argv | string replace -r '\t.*' ''
pactl list short $argv | string replace -r '(\w+)\t.*' '$1'
end end
function __fish_pa_list_ports function __fish_pa_list_ports