Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Alias for subcommands
- X-seq: zsh-workers 49092
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Jörg Sommer <joerg@xxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Alias for subcommands
- Date: Sat, 19 Jun 2021 00:23:53 -0700
- Archived-at: <https://zsh.org/workers/49092>
- In-reply-to: <20210619061334.snrdkfrfucvflvvi@jo-so.de>
- List-id: <zsh-workers.zsh.org>
- References: <20210619061334.snrdkfrfucvflvvi@jo-so.de>
On Fri, Jun 18, 2021 at 11:14 PM Jörg Sommer <joerg@xxxxxxxx> wrote:
>
> would it be possible to have aliases for subcommands?
It's not really possible to have aliases for multiple-word constructs,
but you can create a function that "knows about" subcommands and then
alias the base command to pass through that function.
Very roughly (on the fly, certainly needs work, likely better naming):
use_subcommand_aliases() {
local -a subcommand_expansion
zstyle -a subcommand_alias:$1 $2 subcommand_expansion &&
argv[2]=($subcommand_expansion)
"$@"
}
alias restic="use_subcommand_aliases restic"
zstyle subcommand_alias:restic mount mount --allow-other
--no-default-permissions
Messages sorted by:
Reverse Date,
Date,
Thread,
Author