Re:Zsh 5.9
by sfink on Monday May 16, 2022 @10:50AM
(#31398234)
Perhaps it's niche, but there's a single feature that makes me use zsh over bash: EXTENDED_GLOB, used together with * filename expansion.
ls **/*.d
gives me all files, recursively, that end in .d. That's available in bash too if you `shopt -s starglob`.
But it also gives all directories, so if I do eg
grep pattern **/*.d
then I get lots of error messages about trying to grep on directories (if I happen to have directories ending in .d). With zsh, I can do
grep pattern **/*.d(.)
and it will restrict to just files. I use this pretty often, and it saves me from many `find | xargs` commands. I pretty much only use `find` when there are too many matches for a single command.
My muscle memory types
fgrep -l SOMESTRING **/*(.)
multiple times per day. That'll list out all files containing the literal SOMESTRING anywhere in or below my current directory. I'm sure I could be using one of the fancy grep replacements, and I have in the past, but this works Good Enough and only requires zsh to be installed, so it's what I have held onto.
But it also gives all directories, so if I do eg
then I get lots of error messages about trying to grep on directories (if I happen to have directories ending in .d). With zsh, I can do and it will restrict to just files. I use this pretty often, and it saves me from many `find | xargs` commands. I pretty much only use `find` when there are too many matches for a single command.My muscle memory types
multiple times per day. That'll list out all files containing the literal SOMESTRING anywhere in or below my current directory. I'm sure I could be using one of the fancy grep replacements, and I have in the past, but this works Good Enough and only requires zsh to be installed, so it's what I have held onto.