diff options
author | Fabian Homborg <FHomborg@gmail.com> | 2016-01-14 22:36:50 +0100 |
---|---|---|
committer | Fabian Homborg <FHomborg@gmail.com> | 2016-01-14 22:36:50 +0100 |
commit | 6bf70c86d2b289229a81df94a0c7b8c2addd18dc (patch) | |
tree | 00f7b7a568b740baf3283de826b8c564aa94433d /share/completions/pactl.fish | |
parent | b7d98fa8730f0b4c0926251eb1a9360ad09f3f1a (diff) |
Only complete unloaded modules for pactl load-module
This now officially does more than the official bash completion!
Diffstat (limited to 'share/completions/pactl.fish')
-rw-r--r-- | share/completions/pactl.fish | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/share/completions/pactl.fish b/share/completions/pactl.fish index dfd65a10..a2e3e5ef 100644 --- a/share/completions/pactl.fish +++ b/share/completions/pactl.fish @@ -30,6 +30,19 @@ function __fish_pa_list_profiles env LC_ALL=C pactl list cards ^/dev/null | sed -n -e '/Profiles:/,/Active Profile/p' | string match -r '\t\t.*' | string replace -r '\s+([-+\w:]+): (\w.+)' '$1\t$2' end +# This is needed to filter out loaded modules +function __fish_pa_complete_unloaded_modules + # We need to get just the module names + set -l loaded (__fish_pa_print_type modules | string replace -r '^\w*\t([-\w]+).*' '$1') + pulseaudio --dump-modules | while read name description + # This is a potential source of slowness, but on my system it's instantaneous + # with 73 modules + if not contains -- $name $loaded + printf "%s\t%s\n" $name $description + end + end +end + complete -f -e -c pactl complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a "$commands" @@ -46,8 +59,7 @@ complete -f -c pactl -n "not __fish_seen_subcommand_from $commands" -a remove-sa complete -f -c pactl -n "__fish_seen_subcommand_from play-sample remove-sample" -a '(__fish_pa_complete_type samples)' complete -f -c pactl -n "__fish_seen_subcommand_from unload-module" -a '(__fish_pa_complete_type modules)' -# TODO: This shows _all_ modules -complete -f -c pactl -n "__fish_seen_subcommand_from load-module" -a '(pulseaudio --dump-modules | string replace -r " +" "\t")' +complete -f -c pactl -n "__fish_seen_subcommand_from load-module" -a '(__fish_pa_complete_unloaded_modules)' complete -f -c pactl -n "__fish_seen_subcommand_from move-sink-input; and not __fish_seen_subcommand_from (__fish_pa_print_type sink-inputs)" \ -a '(__fish_pa_complete_type sink-inputs)' |