Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: psychiatric help
- X-seq: zsh-users 30498
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: psychiatric help
- Date: Sun, 5 Apr 2026 19:24:47 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+ShOCkcLru/IfSjM9TW067jRpk0E6mgydYrLneVFCDc=; fh=hSLUtyVkxbQ84ew/DOQBCr+JU3iz+amDTVKA6VBWyHw=; b=T6fKAXDrhtlCoUfNys/fYT3+/LtRBS52GH/pc1+JKbbbxb7+HfHz/eou27rv02x2Sm Yl3EG3RuXf/X5TDbiyMHc6YwcGFSJ30SOySUS2APjVhr2MZaI/qlFp+xTP6GQuPeNet6 nhNN2u6xtrUNhPlGH0VRGbRiJQOz0r6cS3PXhQuLTsaqNV3IM+TqjU3RJXfhR/pHswcA MH5qU80Msf1lWJIL2rtLrL77bBO5blSHfNctsV6F0sWgJWlrSHA2kS0czb7MXx5+krB8 aSDGs6F8A2Xw5QRkkvjMrSzCAQ8BUomk3S5TiQvKsIwySrYxAVSYpMURqF9X+uCdaev7 6deg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1775442300; cv=none; d=google.com; s=arc-20240605; b=cWte223KcKFQ5FZcBDVBB5CIvD6RP9gk7jx5WF/p1b1oWni+Mgz99lghNG35XYm/8w KKVAqLtWZRtIMOUautCd7n9giFviOLTGa2Ip7J82s7qze40JGbp45e1/T1R5n0m1WkIH Oz5E5EA7zA2ZH/gI0CIv5dekQh4Oo16tB4eRFLXpWdOxv4AdDA9DDYfZKm/Qfi8yYHOs Q7Q9Nc/Pff7EA/oFkhoHIXR30Rawj1l8O2hS0a77Y9TQ6Zm97xrNFP+LXVmaH0I5qydW RkZaJ9T9w3+mM6CG3MSpNDrO8bfHMKGdeQ0XY/822fbv4RsvMvgK3EqzEYmV1h7lOAws /I1w==
- Archived-at: <https://zsh.org/users/30498>
- In-reply-to: <e2d7c5e8-b994-4f38-8396-c21d493a617b@eastlink.ca>
- List-id: <zsh-users.zsh.org>
- References: <0610849d-f81c-4539-b13d-c4be9cbd1276@eastlink.ca> <CAA=-s3yUhzu7WbAB0F09abwmzPYowJ1s6o+YiV+cuQBf-GvFXw@mail.gmail.com> <448d6d35-c261-4e7e-bc67-c2a58d082b87@eastlink.ca> <CAA=-s3wKQb+1Sq2mV+h2Gk8rOQYKt8x_JNg9NhmdwAgJesxBkQ@mail.gmail.com> <755f4aa9-e27a-4b4d-8f23-add76a13ee83@eastlink.ca> <CAH+w=7Ydks9vqHA8x_zcHq454q8_C49Tq0xqPWuv9ejKYxCoOA@mail.gmail.com> <fcd552e0-d0eb-4443-bf6a-8ba11663638f@eastlink.ca> <CAH+w=7aksiqTuN4A_203YDWd9RfBwq2X83Oo9z0=45Md6aeWSg@mail.gmail.com> <e2d7c5e8-b994-4f38-8396-c21d493a617b@eastlink.ca>
On Sun, Apr 5, 2026 at 4:41 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Here's why I want to capture the 'tail' literally:
Yes, I got that.
> Thus the tweedle dum and tweedle dee of 'noglob' and 'eval' ... and thus
> these silly issues. If I could access the BUFFER (or wherever) and grab
> the command AS TYPED into some variable
Did you even read what I wrote after "Start this way:" in the previous post?
The place you can access $BUFFER is in the zle-line-finish widget. At
this point globbing (and other expansion including aliasing) has not
happened yet.
After rewriting to the "nauseating to look at" representation, you can
then put that nauseating thing back into BUFFER, as long as you're
still in the zle-line-finish widget.
And then zsh will put the unexpanded thing into the history (whether
that's the original BUFFER or the nauseating rewrite), and afterwards
glob it etc. for actual execution. You no longer need to force the
history with print -rS nor to pass the whole thing to eval -- you've
instead changed what ZLE will send to be executed.
You just have to do a little bit of work to turn the guts of your _l
function into something that will work as a user-defined widget. I
tried to give some hint as to how to go about doing that with as few
changes as possible.
Let me try demonstrating with your simpler example:
function _tt ()
{
set -- ${(z)BUFFER} # Widget doesn't get $@, so create it for clarity
# Next line replaces alias tt='noglob _tt' but see users/30496
[[ $1 = tt ]] || return 0 # Don't mess with other commands
shift # This throws away "tt" leaving only the "tail"
out=( $@ ) # Not really needed, but to keep the example
out=( '(#i)'$^out ) # Prefix every tail with ignore-case
BUFFER="ls -AFrGgdt $out" # Put it back together with "ls" in front
# All done, no need for _execute
}
zle -N zle-line-finish _tt
Try that and observe the result.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author