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

Allow filtering by event type #46

Closed
emcrisostomo opened this issue Aug 23, 2014 · 8 comments
Closed

Allow filtering by event type #46

emcrisostomo opened this issue Aug 23, 2014 · 8 comments

Comments

@emcrisostomo
Copy link
Owner

No description provided.

@grosch
Copy link

grosch commented Aug 28, 2014

I would definitely like this as well. For example, I only want newly created files to appear in the output.

@emcrisostomo
Copy link
Owner Author

Hi @grosch, I expect this issue to be closed quite soon. I'll post updates here.

@RomeshA
Copy link

RomeshA commented Mar 13, 2015

I'd like to second this, I'm writing a script to move newly-created files that are dropped remotely into a folder, but on Linux each file creation results in 4 events (only one of which is creation) - and it can also results in an event on the parent folder. So it's much harder to isolate just the created file

@lucianp
Copy link

lucianp commented Jul 20, 2015

Like the others have said, I think this feature would be extremely useful.
Most of the time we are only interested in actual file changes (CREATE, CLOSE_WRITE, DELETE, MODIFY, MOVED_FROM, MOVED_TO) and we would like to ignore read events (OPEN, ISDIR, CLOSE_NOWRITE, etc.).

I realize that it may not be trivial to implement this in a platform-independent manner, because the events probably differ from one platform to another.
A compromise solution could be to just add a way to filter read events from write events.

Thank you for all the hard work!

@emcrisostomo
Copy link
Owner Author

Hi @lucianp,

you're welcome and thanks, it's appreciated.

Yes, I agree it would be useful. In fact, I'm reviewing the mappings between platform-specific events and "generic" fswatch events soon and implement this.

@emcrisostomo
Copy link
Owner Author

Hi all,

This issue has been fixed in 1.5.0. I'll prepare the OS X ports shortly.

@fanktom
Copy link

fanktom commented May 5, 2017

Hey @emcrisostomo, could you elaborate on how to use the event filters?

I tried

fswatch --event=CLOSE_WRITE files

which I expected to fire only on CLOSE_WRITE events.
Is that the intended behaviour? Unfortunately I could not find any information in the manuals except for:

--event name
      Filter event with the specified name.  This option can be used multiple times, one for each event name that must be included in the output.

Unfortunately, on my linux machine this just immediately exits.

@zachatrocity
Copy link

@fanktom hello from the future.

Leaving this here incase anyone else is having issues using the event filters. I wasn't able to find the event names anywhere on github or the man page.

After looking at the source I found the event names here in the event.cpp

I was able to use the event filters like so:

fswatch --event "Updated" .  

For an even more specific example I used the filters combined with the -i flag to only watch for .scss files being Updated like so:

fswatch --event "Updated" -e ".*" -i "\\.scss$" .

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

No branches or pull requests

6 participants