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
function __fish_pa_complete_type
pactl list short $argv
# 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
pactl list short $argv | string replace -r '(\w+)\t([-\w]+)' '$2\t$1'
# Print a completion candidate for the object type (like "card" or "sink"),
# with a description.
# 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
function __fish_pa_print_type
pactl list short $argv
# Pa allows both a numerical index and a name
pactl list short $argv | string replace -r '(\w+)\t.*' '$1'
# Print just the object, without description
__fish_pa_complete_type $argv | string replace -r '\t.*' ''
end
function __fish_pa_list_ports