On 7/22/21 2:51 AM, Peter Slížik wrote:
is it possible to define something like "aliases" (apologies for the lack of a better term) for command completion?
I believe that you can define aliases of shorter commands in place of longer commands. But I'm not sure how that would interact with command completion as such.
If the completed command consists of multiple words, I would like to be
able to type the first letters of individual words and have this abbreviation expanded to the whole command name (taking into account that the abbreviation is not a prefix of the completed text).
First words ($0) can use normal aliases. Subsequent words (>= $1) will
need global aliases.
For example: ome<Tab> => outcomingmessageeditor cs<Tab> => changestatus
Those are all single words ($0) to me.Your request seems to be very similar to something that I asked about a while ago. TL;DR: I tried overloading space as a completion character (in addition to tab) and had some strange side effects and ended up abandoning it.
I was wanting something akin to what Cisco IOS (classic) and Juniper Junos do. Wherein "sh ru" gets treated as if it was "show run" because of the unabiguity in that there were no other commands that start with "sh" or parameters thereto that start with "ru". Thus Cisco IOS was able to deduce that the command is "show run".
Juniper Junos does something slightly different. Junos does treat the space very much like the completion key. If I type "sh" followed by a space, it interactively expands command to be "show ". When I type "conf" followed by a space, it expands it to be "configuration".
Despite being different, both the Cisco IOS and Juniper Junos method achieve similar effects. I've not yet found a way to accomplish this (without negative side effects) in Zsh.
Aside: My brain sort of likes the Cisco IOS method for brevity / characters sent (think old serial / modem connections). But I strongly prefer the full command a la Juniper Junos for documentation / training purposes. You need to know that "sh ru" is "show run" or that "conf t" is "configure terminal". It's harder to learn something from the abbreviation than it is to learn from the full command.
I don't know if this is what you're asking about, or just coincidentally similar.
-- Grant. . . . unix || die
Description: S/MIME Cryptographic Signature