Re: psychiatric help

Ray Andrews <[email protected]> Sun, 5 Apr 2026 16:41:33 -0700
Newsgroups gmane.comp.shells.zsh.user
Message-ID <[email protected]>

On 2026-04-05 12:00, Bart Schaefer wrote:
> On Sun, Apr 5, 2026 at 10:28 AM Ray Andrews <[email protected]> wrote:
>> Tried this:
>>
>> alias tt='noglob _tt'
>> function _tt ()
>> {
>> out=( $@ )                # Bart sez.  Array will preserve hard space, no backslash needed.
>> _execute 'ls $~out'    # Need tilde here!
> This is a bit inside-out if not exactly backward.
Bbbbbut it works.  And it has to be exactly as shown.
> Please note that:
> 1)  $~out does nothing here because of the single quotes around it.
Nothing?  Without it nothing happens at all.  It gets sent to eval which 
chews on it and all's well.
> 3) None of that would be necessary if you weren't prefixing with noglob
I know it.

Here's why I want to capture the 'tail' literally:

5 /aWorking/Zsh/Source/Wk 11 % l ,v test\ ?

  0 [26-04-04--09:00] test a
  0 [26-04-04--09:03] test b

5 /aWorking/Zsh/Source/Wk 11 % l ,Hv test\ ?

  0 [26-04-04--09:00] test a
  0 [26-04-04--09:03] test b

... ',H' option writes the expanded guts of the 'l' wrapper to history 
such that the up arrow retrieves it (this is done in '_execute'):

[up arrow]

5 /aWorking/Zsh/Source/Wk 11 % ls --time-style='+[%y-%m-%d--%H:%M]' 
--group-directories-first -AFrGgdt --color=always (#i)test\ ? 2> 
/dev/null | sed -r "s/^(.{10} {1,3}[[:digit:]]{1,3} )/ /" | egrep -v 
'^total' | sed '/;34m\.\x1b\[0m\/$/d' | perl -pe "s|\] (.*?)(test\ 
)(.*)/|\] \1^[[31;1m\2^[[34;1m\3/|i"  | perl -pe "s|\] (.*?)(test\ )|\] 
\1^[[31;1m\2^[[0m|i"

... its nauseating to look at but it's just an accumulation of tweaks to 
'ls' output.  Some trivial but I may as well have things looking exactly 
the way I want.  And I have a thing about color. But for debugging, it 
is sure easier to tinker with the final command above than to wonder 
where I went wrong inside my function. I fiddle with the above, then 
know exactly what needs fixing in the function.  It's invaluable. Or 
was.  My stuff is pretty stable now.

But here's the hitch: half way across on the 2nd line you see:  >  
  test\ ?   <
... the command tail AS TYPED.  If I let zsh expand it, it could expand 
to hundreds of files.  Nuts it could expand to my whole disk in some 
situations and I don't want that sent to history.   Also, some of the 
coloring needs the unexpanded tail string too.

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, then the whole show would get a 
whole lot simpler.  Goodby eval.  As I'm imagining it, something in 
preexec() would do this all the time.  I'd have my variable in there: 
COMMAND_TAIL_AS_TYPED.  Or ... really the whole thing, just skip $1 to 
get the tail.  So the var would be COMMAND_AS_TYPED.  I guess the 
exception would be command recall commands which are 'commands about 
commands' so to speak.

Very unorthodox I know.  But there's gotta be a way of grabbing the CL 
buffer before any processing.  No grief tho, all my stuff works fine, 
but I'm sure it could be simpler.