From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: array with newlines preserved as literal text
Date: Tue, 2 Feb 2021 15:31:06 -0800 [thread overview]
Message-ID: <36596ab3-14b6-da57-e40b-3e66d9ffbb5a@eastlink.ca> (raw)
In-Reply-To: <CAH+w=7bAZKawy_BfTMGzuCm96NB=gDA6R-K9aZBd4N+uOOT-=A@mail.gmail.com>
On 2021-02-02 12:25 p.m., Bart Schaefer wrote:
> On Tue, Feb 2, 2021 at 11:16 AM Ray Andrews <rayandrews@eastlink.ca> wrote:
>>
>> I'm curious why you want to save this in the form of a command to be
>> eval'd rather than just save the argument string?
Complicated. It goes back to my first bitch with zsh, namely not being
able to capture the literal invocation of a function (along with it's
tail) unexpanded, just as you'd see in history. (History would work
fine except for the fact that several commands can end up on the same
line.) Basically my wrappers do some heavy duty massaging of output and
both for debugging and or for modification it's good to be able to
recall the actual commands executed. My function '_execute' does that,
it calls 'eval' but does other stuff too like store to history. Here's
a sample:
$ l ,Hs c,* # 'l' wraps 'ls' and colorizes and formats the output as
I like:
LISTING of "c,*": all file types, INsensitive. Sorting upside down by:
File Size:
10746 [2020-12-20--14:48] c,34
11168 [2020-12-27--10:39] c,35,localized help
11219 [2020-12-27--10:45] c,36
11348 [2020-12-28--13:30] c,38,delete deleted directories
11428 [2020-12-28--10:46] c,37,trivial
11665 [2020-12-28--16:17] c,39
11833 [2020-12-28--16:48] c,40,misc
13253 [2020-12-28--19:48] c,41,polishing
13376 [2020-12-28--20:09] c,42,messages improved
13383 [2020-12-29--07:02] c,43,before improved cd
14045 [2021-01-31--11:08] c,55,more one line bugs
14053 [2021-01-31--13:05] c,56,trivial edits
14156 [2021-01-30--10:48] c,54,rationalize switches
14184 [2021-01-24--20:47] c,52,interim
14186 [2021-01-29--06:17] c,53,more sky trouble. big code purge
14494 [2020-12-30--06:17] c,44,better cd to incomplete name
14925 [2020-12-30--11:55] c,47,massive edit old code purged
15493 [2020-12-30--09:41] c,45,working huge edit
15741 [2021-01-31--10:48] c,48,good old Sky above was truncated
16080 [2020-12-30--10:06] c,46,bad
16394 [2021-01-07--08:49] c,50
Items found: 1
Total bytes in this directory: 2.9M
Total including subdirs: 15M
... the ',H' switch stores the actual working code to history. Hit the
up arrow and:
$ ls -AFrGgdS --time-style='+[%F--%H:%M]' --group-directories-first
--color=always (#i)c,* 2> /dev/null | sed -r "s|^(.{10} [[:digit:]]
)| |" | egrep -v '^total' | egrep -i --color=always "^|] c,*" | sed -r
"s/\x1b\[01;31m\x1b\[K\] /\] \x1b\[01;31m\x1b\[K/g"
... hit ENTER and exactly the same output occurs. Or modify to suit, or
perhaps to chase down a bug.
But it requires execution to be put off, thus the need for an eval
contained within '_execute'. Meanwhile let's see what Roman has for me.
next prev parent reply other threads:[~2021-02-02 23:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 19:16 Ray Andrews
2021-02-02 19:26 ` Roman Perepelitsa
2021-02-03 1:10 ` Ray Andrews
2021-02-02 20:25 ` Bart Schaefer
2021-02-02 23:31 ` Ray Andrews [this message]
2021-02-03 2:21 ` Bart Schaefer
2021-02-03 19:29 ` Ray Andrews
2021-02-03 21:19 ` Bart Schaefer
2021-02-04 2:07 ` Ray Andrews
2021-02-05 2:57 ` Bart Schaefer
2021-02-04 21:55 ` Ray Andrews
2021-02-05 3:22 ` Bart Schaefer
2021-02-05 4:17 ` Ray Andrews
2021-02-05 4:24 ` 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=36596ab3-14b6-da57-e40b-3e66d9ffbb5a@eastlink.ca \
--to=rayandrews@eastlink.ca \
--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).