Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't ignore files starting with '.#' #276

Open
thoni56 opened this issue May 18, 2021 · 1 comment
Open

Can't ignore files starting with '.#' #276

thoni56 opened this issue May 18, 2021 · 1 comment

Comments

@thoni56
Copy link

thoni56 commented May 18, 2021

I'm looking to watch all C files but ignore Emacs lock files. E.g.

file.c # should match
.#file.c # should not match

I've tried various patterns, but as far as I could figure out by toying with https://www.regextester.com, the following should match

fswatch -e '.*' -i '^(?!\.#).*$' .

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.)

@direvus
Copy link

direvus commented Apr 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants