[-- Attachment #1: Type: text/plain, Size: 724 bytes --] I've written a neat little tool that wraps "fc" / "history" to make everything look neat and easily documentable for later reference / incident response. $ command echo 'Hello, zsh-users!' Hello, zsh-users! $ hgrep zsh-u # [2021-12-18 06:13] git clone https://github.com/zsh-users/zsh.git # [2022-02-21 11:39] command echo 'Hello, zsh-users!' The down-side of this is that it appears "fc ... -m expression" is case-sensitive. I expect that Zsh has excellent documentation on the patterns and how to make them case-insensitive but I haven't managed to find it yet. Most of what I've found seems to correspond to file globbing, which isn't what I'm trying to do here. Any tips? Zach Riggle [-- Attachment #2: image.png --] [-- Type: image/png, Size: 36950 bytes --]
On 2/21/22, Zach Riggle <zachriggle@gmail.com> wrote:
> I've written a neat little tool that wraps "fc" / "history" to make
> everything look neat and easily documentable for later reference /
> incident response.
>
> $ command echo 'Hello, zsh-users!'
> Hello, zsh-users!
>
> $ hgrep zsh-u
> # [2021-12-18 06:13]
> git clone https://github.com/zsh-users/zsh.git
>
> # [2022-02-21 11:39]
> command echo 'Hello, zsh-users!'
>
> The down-side of this is that it appears "fc ... -m expression" is
> case-sensitive. I expect that Zsh has excellent documentation on the
> patterns and how to make them case-insensitive but I haven't managed
> to find it yet. Most of what I've found seems to correspond to file
> globbing, which isn't what I'm trying to do here.
You can use (#i) to make a pattern case insensitive, eg
fc -m '(#i)*zsh-u*'
you may need to setopt extendedglob first.
--
Mikael Magnusson
On 21/02/2022 21:01, Mikael Magnusson wrote:
> On 2/21/22, Zach Riggle <zachriggle@gmail.com> wrote:
>> I've written a neat little tool that wraps "fc" / "history" to make
>> everything look neat and easily documentable for later reference /
>> incident response.
>>
> You can use (#i) to make a pattern case insensitive, eg
> fc -m '(#i)*zsh-u*'
>
> you may need to setopt extendedglob first.
>
Thanks Mikael for resolving this
(i needed the -nl)
fc -nl -m '(#i)*Mortg*'
but there's something clunky with the fc -m match .. I can't get to
match all of my history?
and i fing it simpler to
alias hg='fc -l 1 | grep -i '
zzapper
> On 22 February 2022 at 09:09 zzapper <zsh@rayninfo.co.uk> wrote:
> On 21/02/2022 21:01, Mikael Magnusson wrote:
> > On 2/21/22, Zach Riggle <zachriggle@gmail.com> wrote:
> >> I've written a neat little tool that wraps "fc" / "history" to make
> >> everything look neat and easily documentable for later reference /
> >> incident response.
> >>
> > You can use (#i) to make a pattern case insensitive, eg
> > fc -m '(#i)*zsh-u*'
> >
> > you may need to setopt extendedglob first.
> >
> Thanks Mikael for resolving this
>
> (i needed the -nl)
>
> fc -nl -m '(#i)*Mortg*'
>
> but there's something clunky with the fc -m match .. I can't get to
> match all of my history?
Try sticking a "1" at the end of the line to get the whole history.
It still does the match, but it now starts searching from the beginning.
pws
On 22/02/2022 09:27, Peter Stephenson wrote:
>> On 22 February 2022 at 09:09 zzapper <zsh@rayninfo.co.uk> wrote:
>> On 21/02/2022 21:01, Mikael Magnusson wrote:
>>
>> Thanks Mikael for resolving this
>>
>> (i needed the -nl)
>>
>> fc -nl -m '(#i)*Mortg*'
>>
>> but there's something clunky with the fc -m match .. I can't get to
>> match all of my history?
> Try sticking a "1" at the end of the line to get the whole history.
> It still does the match, but it now starts searching from the beginning.
>
> pws
# pws: yes thanks the following works
fc -l -m '(#i)*Mortg*' 1
(should this be documented?)
zzapper
# pws: yes thanks the following works
>
> fc -l -m '(#i)*Mortg*' 1
>
>
> (should this be documented?)
>
> zzapper
>
>
To answer my own question: with fc any number range eg first last
should/must be the last
Best regards
David Rayner
> On 22 February 2022 at 09:47 zzapper <zsh@rayninfo.co.uk> wrote: > # pws: yes thanks the following works > > > > fc -l -m '(#i)*Mortg*' 1 > > > > > > (should this be documented?) > > > > zzapper > > > > > To answer my own question: with fc any number range eg first last > should/must be the last Would this be a little clearer? History (pun intended) shows that making the docs more verbose doesn't mean people necessarily find them clearer, but I think they are particularly terse at this point. pws diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index c7de50f..dbb787f 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -756,15 +756,16 @@ specifies the most recent event beginning with the given string. All substitutions var(old)tt(=)var(new), if any, are then performed on the text of the events. -In addition to the number range, +The range of events selected by numbers can be narrowed further by the +following flags. startsitem() sitem(tt(-I))(restricts to only internal events (not from tt($HISTFILE))) sitem(tt(-L))(restricts to only local events (not from other shells, see tt(SHARE_HISTORY) in ifzman(zmanref(zshoptions))\ ifnzman(noderef(Description of Options)) -- note that tt($HISTFILE) is considered local when read at startup)) -sitem(tt(-m))(takes the first argument as a pattern (should be quoted) and -only the history events matching this pattern are considered) +sitem(tt(-m))(takes the first argument as a pattern (which should be +quoted) and only the history events matching this pattern are considered) endsitem() If var(first) is not specified, it will be set to -1 (the most recent
On 22/02/2022 10:18, Peter Stephenson wrote:
>> To answer my own question: with fc any number range eg first last
>> should/must be the last
> Would this be a little clearer? History (pun intended) shows that
> making the docs more verbose doesn't mean people necessarily find
> them clearer, but I think they are particularly terse at this point.
>
> pws
Peter you made me laugh out loud when you used the word 'terse'
I often find I understand documentation AFTER I have actually found out
how to do something LOL (especially assembling flat-pack furniture).
But as you say there is trade-off between verbosity which people may not
read and simplicity.
In this case however had I really invested in understanding the existing
fc man page I would spared myself considerable grief.
Isn't there an adage something like '6 hours of coding and testing saves
1 hour of studying the documentation'?
zzapper