FFFF abbr: Allow restricting to a specific command's arguments · Issue #9411 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

abbr: Allow restricting to a specific command's arguments #9411

@faho

Description

@faho

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0