Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Fake parameter completion?
- X-seq: zsh-users 24365
- From: Chris Nebel <c.nebel@xxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Fake parameter completion?
- Date: Fri, 18 Oct 2019 14:08:02 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mac.com; s=1a1hai; t=1571432883; bh=H1LtJm1h+waMMxbBHmAADfQ0huYOSkk9psUf/iVaW3E=; h=From:Content-Type:Subject:Message-Id:Date:To; b=SUHbXsV4rQq3gAQ3YdZL1A+/tj1LG8ncNTJlzbtZKdJmTA2jUdWTA0s6uUI8FC3ug HplTT8x5pCl7/vj7+CdZ/Zh3E4YSDhhui/m9ku5PQdiTMnLT0uJXR8CI2CQiGAblZH ElXRNS4MSfCiIW9vmv7kwJbC+yM+7jfK5iaIoy5hEJd6pgYXivim6XixG4Umt6Te3d Ire6EHSCTU07zUMmtWmhTksUR17ht5gJV3DlEh8b1vyNwEVFaeKzYvmXQsfsNaI3Vt DNA+rbjfnwtt542Zet2+JdsWCRhoRWn/zmBFCdHBXXeiw9cpkDMDWMcadHgaXTqkP+ ms5dkQU7flyjw==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
zsh-users—
I wanted to use autocompletion to complete various “debugging” environment variables, and I came up with something that works, but I don’t understand why it works and some other attempts don’t. First, the task: sh derivatives let you specify extra environment variables for a command by writing them before the command, something like this:
% UseExtraSpiffyLogging=1 ./mytool
The point is that they are ordinarily undefined, so normal parameter completion won’t match them, but I want them completed anyway. Sounds like a job for the “fake” style, which I’ve successfully used in the past; that plus _complete_help led me to this:
zstyle ':completion:complete:-command-::parameters' fake UseExtraSpiffyLogging
This sort of works, but completes “UseEx<tab>” to “UseExtraSpiffyLogging<space>” when really I want no space, or ideally a magic “=“. Re-reading the documentation, I found the “fake-parameters” style. My first attempt didn’t complete anything at all:
zstyle ':completion:complete:-command-::parameters' fake-parameters UseExtraSpiffyLogging
…so I relaxed the context a bit, and now I get the completion *with* the magic “=“, which is perfect:
zstyle ':completion:complete:-command-::*' fake-parameters UseExtraSpiffyLogging
…except that now I have questions:
1. Why are “fake” and “fake-parameters” distinct styles? Obviously they behave differently in practice, but why couldn’t “fake” take the position into account and add the magic “=“ like “fake-parameters” does? (The answer probably has to do with the *other* additional feature that “fake-parameters” provides, which is type-sensitivity, though it seems like “fake” could still do the magic “=“.)
2. What is the actual value of the “*” in the context? Not “parameters”, apparently. (I should mention that I do not truly understand zshcompsys.)
Thanks,
—Chris N.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author