diff --git a/share/completions/doas.fish b/share/completions/doas.fish index 411d67a41..e56071ec4 100644 --- a/share/completions/doas.fish +++ b/share/completions/doas.fish @@ -24,7 +24,7 @@ end function __fish_complete_doas_subcommand set -l args (__fish_doas_print_remaining_args) set -lx -a PATH /usr/local/sbin /sbin /usr/sbin - complete -C"$args" + complete -C "$args" end complete -c doas -n "not __fish_doas_print_remaining_args" -s a -d "Choose auth method on systems using /etc/login.conf" diff --git a/share/completions/su.fish b/share/completions/su.fish index 83115209b..410f22c19 100644 --- a/share/completions/su.fish +++ b/share/completions/su.fish @@ -2,7 +2,7 @@ complete -x -c su -a "(__fish_complete_users)" complete -c su -s l -l login -d "Make login shell" -complete -r -c su -s c -l command -d "Pass command to shell" -xa "(complete -C(commandline -ct))" +complete -c su -s c -l command -d "Pass command to shell" -xa "(__fish_complete_external_command)" complete -c su -s f -l fast -d "Pass -f to the shell" complete -c su -s m -l preserve_environment -d "Preserve environment" complete -c su -s p -d "Preserve environment" diff --git a/share/completions/sudo.fish b/share/completions/sudo.fish index f092fddce..f432b5334 100644 --- a/share/completions/sudo.fish +++ b/share/completions/sudo.fish @@ -34,7 +34,7 @@ end function __fish_complete_sudo_subcommand set -l args (__fish_sudo_print_remaining_args) set -lx -a PATH /usr/local/sbin /sbin /usr/sbin - complete -C"$args" + complete -C "$args" end # All these options should be valid for GNU and OSX sudo diff --git a/share/completions/svn.fish b/share/completions/svn.fish index 6590ac876..7e02653d3 100644 --- a/share/completions/svn.fish +++ b/share/completions/svn.fish @@ -172,7 +172,7 @@ for cmd in $blame $diff $log $merge end for cmd in $cleanup $merge $switch $update - _svn_cmpl_ $cmd -l diff3-cmd -d 'Use as merge command' -xa "(complete -C(commandline -ct))" + _svn_cmpl_ $cmd -l diff3-cmd -d 'Use as merge command' -xa "(__fish_complete_external_command)" end for cmd in $blame $info $list $log $stat @@ -193,7 +193,7 @@ end for cmd in $diff $log _svn_cmpl_ $cmd -l internal-diff -d 'Override diff-cmd specified in config file' - _svn_cmpl_ $cmd -l diff-cmd -d 'Use external diff command' -xa "(complete -C(commandline -ct))" + _svn_cmpl_ $cmd -l diff-cmd -d 'Use external diff command' -xa "(__fish_complete_external_command)" end for cmd in $add $import diff --git a/share/completions/type.fish b/share/completions/type.fish index e9598c7f0..e58ba1de2 100644 --- a/share/completions/type.fish +++ b/share/completions/type.fish @@ -10,4 +10,4 @@ complete -c type -s q -l quiet -d "Suppress output" complete -c type -a "(builtin -n)" -d "Builtin" complete -c type -a "(functions -n)" -d "Function" -complete -c type -a "(complete -C(commandline -ct))" -x +complete -c type -a "(__fish_complete_command)" -x diff --git a/share/completions/which.fish b/share/completions/which.fish index d6c6decef..1b54defc9 100644 --- a/share/completions/which.fish +++ b/share/completions/which.fish @@ -16,4 +16,4 @@ else # OSX complete -c which -s s -d "Print no output, only return 0 if found" end -complete -c which -a "(complete -C(commandline -ct))" -x +complete -c which -a "(__fish_complete_external_command)" -x diff --git a/share/completions/xterm.fish b/share/completions/xterm.fish index 036d0643e..b8c254d73 100644 --- a/share/completions/xterm.fish +++ b/share/completions/xterm.fish @@ -98,7 +98,7 @@ complete -c xterm -o wc -d 'Use wide characters' complete -c xterm -o wf -d 'Wait the first time for the window to be mapped' complete -c xterm -o Sccn -d 'Use as input/output channel for an existing program' -complete -c xterm -s e -a "(complete -C(commandline -ct))" -x -d 'Run program in xterm' +complete -c xterm -s e -a "(__fish_complete_external_command)" -x -d 'Run program in xterm' complete -r -c xterm -o bcf -d 'Blinking cursor will be off for that many milliseconds' complete -r -c xterm -o bcn -d 'Blinking cursor will be on for that many milliseconds' diff --git a/share/functions/__fish_complete_command.fish b/share/functions/__fish_complete_command.fish index f6cc7e20a..ddbfb0273 100644 --- a/share/functions/__fish_complete_command.fish +++ b/share/functions/__fish_complete_command.fish @@ -3,8 +3,10 @@ function __fish_complete_command --description 'Complete using all available com switch $ctoken case '*=*' set ctoken (string split "=" -- $ctoken) - printf '%s\n' $ctoken[1]=(complete -C$ctoken[2]) + printf '%s\n' $ctoken[1]=(complete -C "$ctoken[2]") + case '-*' # do not try to complete options as commands + return case '*' - complete -C$ctoken + complete -C "$ctoken" end end diff --git a/share/functions/__fish_complete_external_command.fish b/share/functions/__fish_complete_external_command.fish index 218aee4f3..2790c61e7 100644 --- a/share/functions/__fish_complete_external_command.fish +++ b/share/functions/__fish_complete_external_command.fish @@ -1,3 +1,3 @@ function __fish_complete_external_command - command find $PATH/ -maxdepth 1 -perm +u+x 2>&- | string match -r '[^/]*$' + command find $PATH/ -maxdepth 1 -perm -u+x 2>&- | string match -r '[^/]*$' end diff --git a/share/functions/__fish_complete_subcommand.fish b/share/functions/__fish_complete_subcommand.fish index 9f5ac1d59..79496d6d2 100644 --- a/share/functions/__fish_complete_subcommand.fish +++ b/share/functions/__fish_complete_subcommand.fish @@ -39,7 +39,7 @@ function __fish_complete_subcommand -d "Complete subcommand" --no-scope-shadowin end end - printf "%s\n" (complete -C$res) + printf "%s\n" (complete -C "$res") end