From: Grant Taylor <gtaylor@tnetconsulting.net>
To: zsh-users@zsh.org
Subject: Re: Aliases (abbreviations) for command completion?
Date: Thu, 22 Jul 2021 11:50:48 -0600 [thread overview]
Message-ID: <f224d699-a4a7-1e12-5533-64ea23d4b670@spamtrap.tnetconsulting.net> (raw)
In-Reply-To: <CAC-uhUDmc3doMhVBzmC7UmPAY_e3Y7_MsopEFQFsarBuWZ2jew@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2459 bytes --]
On 7/22/21 2:51 AM, Peter Slížik wrote:
> Hello,
Hi,
> 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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4013 bytes --]
next prev parent reply other threads:[~2021-07-22 17:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 8:51 Peter Slížik
2021-07-22 17:50 ` Grant Taylor [this message]
2021-07-22 21:03 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f224d699-a4a7-1e12-5533-64ea23d4b670@spamtrap.tnetconsulting.net \
--to=gtaylor@tnetconsulting.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).