Open thoni56 opened 3 years ago
Try this:
fswatch -E -i '^[^.]+\.c$' -e '.*' .
The regular expression ^[^.]+\.c$
means "A string beginning with one or more characters that are not .
, followed by a .
, followed by c
ending the string".
This should work fine for files that are in the top-level directory. If you're hoping to catch C files in subdirectories, you'll have to make the include pattern more clever to account for that.
Lookaheads and lookbehinds can be handy for some situations, but support for them varies considerably from one regex engine to another. It's better not to rely on them unless absolutely necessary.
I'm looking to watch all C files but ignore Emacs lock files. E.g.
I've tried various patterns, but as far as I could figure out by toying with https://www.regextester.com, the following should match
But I can't get that to work. I can't find a pointer to the exact regex specification that fswatch uses. (Actually I don't know if negative lookahead is considered "extended", but adding
-E
causes compilation of regex error.)