mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
22ce8c23c6
This is a long-standing issue with how `complete --do-complete` does its argument parsing: It takes an optional argument, so it has to be attached to the token like `complete --do-complete=foo` or (worse) `complete -Cfoo`. But since `complete` doesn't take any bare arguments otherwise (it would error with "too many arguments" if you did `complete -C foo`) we can just take one free argument as the argument to `--do-complete`. It's more of a command than an option anyway, since it entirely changes what the `complete` call _does_.
29 lines
897 B
Fish
29 lines
897 B
Fish
logmsg Completion Wrappers
|
|
|
|
function complete_test_alpha1; echo $argv; end
|
|
|
|
complete -c complete_test_alpha1 --no-files -a '(commandline)'
|
|
complete -c complete_test_alpha2 --no-files -w 'complete_test_alpha1 extra1'
|
|
complete -c complete_test_alpha3 --no-files -w 'complete_test_alpha2 extra2'
|
|
|
|
complete -C'complete_test_alpha1 arg1 '
|
|
complete -C'complete_test_alpha2 arg2 '
|
|
complete -C'complete_test_alpha3 arg3 '
|
|
# Works even with the argument as a separate token.
|
|
complete -C 'complete_test_alpha3 arg3 '
|
|
|
|
logmsg Alias Completions
|
|
|
|
alias myalias1 'complete_test_alpha1 arg1'
|
|
alias myalias2='complete_test_alpha1 arg2'
|
|
|
|
myalias1 call1
|
|
myalias2 call2
|
|
complete -C'myalias1 call3 '
|
|
complete -C'myalias2 call3 '
|
|
|
|
# Ensure that commands can't wrap themselves - if this did,
|
|
# the completion would be executed a bunch of times.
|
|
function t --wraps t; echo t; end
|
|
complete -c t -fa '(t)'
|
|
complete -C't '
|