Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Using history / fc for case-insensitive pattern matching

On 2/21/22, Zach Riggle <zachriggle@xxxxxxxxx> 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

Messages sorted by: Reverse Date, Date, Thread, Author