completions/abbr: complete function names if --function is given

This commit is contained in:
Johannes Altmanninger 2022-12-17 17:39:27 +01:00
parent d61f1d75a8
commit 0db10056e7

View File

@ -1,6 +1,11 @@
# "add" is implicit.
set __fish_abbr_not_add_cond '__fish_seen_subcommand_from --query --rename --erase --show --list --help'
set __fish_abbr_add_cond 'not __fish_seen_subcommand_from --query --rename --erase --show --list --help'
function __fish_abbr_add_function_cond
argparse -s h/help a/add p/position= f/function r/regex= set-cursor=? \
-- (commandline -opc)[2..-1] 2>/dev/null
and test (count $argv) -eq 1
end
complete -c abbr -f
complete -c abbr -f -n $__fish_abbr_not_add_cond -s a -l add -d 'Add abbreviation'
@ -16,3 +21,4 @@ complete -c abbr -f -n $__fish_abbr_add_cond -s p -l position -a 'command anywhe
complete -c abbr -f -n $__fish_abbr_add_cond -s f -l function -d 'Treat expansion argument as a fish function'
complete -c abbr -f -n $__fish_abbr_add_cond -s r -l regex -d 'Match a regular expression' -x
complete -c abbr -f -n $__fish_abbr_add_cond -l set-cursor -d 'Position the cursor at % post-expansion'
complete -c abbr -f -n "$__fish_abbr_add_cond && __fish_abbr_add_function_cond" -a '(functions)' -d "Expand to output of this function"