mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:56:09 +08:00
Complete empty subcomands consistently
If the command is empty, try to complete starting from the empty command instead of the whole commandline.
This commit is contained in:
parent
12e783e30e
commit
36693e4391
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user