From 5f26c56ed546b3a63adc4dfeca1767e5cf3463ce Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 19 Jul 2023 18:07:03 +0200 Subject: [PATCH] completions/pactl: Fix matching objects This didn't work for something like `pactl set-card-profile foo `, because it didn't allow for the card name, as it would just print the index again and again. --- share/completions/pactl.fish | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/share/completions/pactl.fish b/share/completions/pactl.fish index 67bc4cf42..6da1b8872 100644 --- a/share/completions/pactl.fish +++ b/share/completions/pactl.fish @@ -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