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_c
This is supposed to allow adding abbreviations for git subcommands. It would be cool if this could be
abbr --add --command git c checkout
Which 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).
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:
This is supposed to allow adding abbreviations for git subcommands. It would be cool if this could be
Which 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 falsewill 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 argumentor require--position anywherejust for this. I also don't think we'd need to walk a command's wrap chain (i.e.function g; git $argv; endwould need to have the abbrs specified again).