-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
This is very much a nice-to-have, it does not need to be in the initial release with "Mega abbr".
One of the examples in #9313:
function git_c
string match --quiet 'git c ' -- (commandline -j); or return 1
echo checkout
end
abbr -a git_c --position anywhere --regex c --function git_cThis is supposed to allow adding abbreviations for git subcommands. It would be cool if this could be
abbr --add --command git c checkoutWhich allows us to save the regex, makes for easier and more correct matching and allows arbitrary transformations with arbitrary regexen without marking everything as not-an-error.
(Currently abbr hahaha --regex '.*' --function false will cause commands to always be marked as valid because the regex matches and it can't know that the function would fail. This is probably correct - I don't think we can run the function before and marking things as invalid even tho they could still match an abbr feels weird?)
Note that this would always be restricted to a command argument - because otherwise the command won't match. I don't think we need to add --position argument or require --position anywhere just for this. I also don't think we'd need to walk a command's wrap chain (i.e. function g; git $argv; end would need to have the abbrs specified again).