From c9841fb77d5dad6913ec7769281ffa92b9df165f Mon Sep 17 00:00:00 2001 From: Paul Seyfert Date: Tue, 8 Nov 2016 12:28:55 +0100 Subject: [PATCH] updated completion for pasuspender * remove suggestion of '-C' due to incorrect ordering of options for _arguments * avoid suggesting multiple options * add suggestion of "--", followed by executable programs * after "--server=" or "-s " suggest "--" * after "-- " continue standard tab completion --- shell-completion/zsh/_pulseaudio | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/shell-completion/zsh/_pulseaudio b/shell-completion/zsh/_pulseaudio index e065085..7d9fb76 100644 --- a/shell-completion/zsh/_pulseaudio +++ b/shell-completion/zsh/_pulseaudio @@ -600,10 +600,26 @@ _pacmd_completion() { } _pasuspender_completion() { - _arguments -S -A "-*" -C \ - {-h,--help}'[display help and exit]' \ - '--version[show version and exit]' \ - {-s,--server=}'[name of server to connect to]:host:_hosts' \ + # parenthesis expressions specify which options should not get suggested afterwards + # e.g. after -s, help and version will not get suggested, -- remains the only valid argument + # after "--" external commands get suggested + _arguments -C \ + '(-)'{-h,--help}'[display help and exit]' \ + '(-)--version[show version and exit]' \ + '(-h --help --version -s --server)'{-s,--server=}'[name of server to connect to]:host:_hosts' \ + '(-)--[program]:program: _command_names -e' && return 0 + # check if "--" is one of the words in the command line + # if so, ${words[(i)--]} is the position of "--" + # shift the arguments and reduce CURRENT, such that further completions see only what follows "--" + if [[ ${words[(r)--]} == "--" ]]; then + for ((j = ${words[(i)--]}; j > 0; j--)); + do + shift words + (( CURRENT-- )) + done + # proceed with normal completion + _normal + fi } _padsp_completion() { -- 2.1.4