10 days ago · Tech · hide

By default, Zsh globs are case-sensitive, so *.jpg matches beach.jpg but not CAT.JPG or dog.Jpg: $ ls photos/*.jpg photos/beach.jpg This is true even on macOS, where the filesystem is case-insensitive by default. Zsh shares this behaviour with Bash, but provides per-glob and global controls to make your globs case-insensitive and match all the files you probably meant. Per-glob with (#i) To make a single glob case-insensitive, use the (#i) glob flag, which makes the rest of the pattern case-insensitive: $ ls photos/*.(#i)jpg photos/CAT.JPG photos/beach.jpg photos/dog.Jpg Glob flags require the extended_glob option, which you can enable in your ~/.zshrc: setopt extended_glob Without it, Zsh treats (#i) as part of the pattern, leading to a confusing “no matches found” error. Flag placement (#i) applies from where it appears until the end of the pattern, including across directory separators. So you can put it at the start to make the whole pattern case-insensitive. For example, to find…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town