Comments (13)
If anyone is interested to just run a command without passing changed files, you need to replace this:
$ fswatch . | xargs -n1 echo updated
updated /path/to/file
updated /path/to/file
updated /path/to/file
With this:
$ fswatch -o . | xargs -n1 -I "{}" echo updated
updated
updated
updated
Substitute "echo updated" with your own command.
from fswatch.
I was also surprised today when my work setup suddenly stopped working :(
Are we expected to run a while true; do fswatch --one-event && mycmd; done
loop now? Feels like going backwards.
from fswatch.
Hi @bwiklund, @ricardobeat, @jenmontes,
I've just released v. 1.3.3 where:
- The
-o
option instructsfswatch
to only print one line with the number of the change events received in the last "batch". This way, you can use this event to trigger the execution of another program, as discussed in this issue and in Issue 20. - The
fswatch-run
script has been added to ease the transition from v. 0.x to 1.x. This scripts accepts the olderfswatch path command
syntax and invokesfswatch -o
piping its output toxargs
for you. Being a one-liner, I still strongly suggest adapting your script to the new behaviour.
from fswatch.
FYI this is on version 1.3.2 via brew
from fswatch.
I'm also having this issue. I'm on OS X 10.9.2 and fswatch
1.3.2.
from fswatch.
Hi @bwiklund, @ricardobeat, @jenmontes,
fswatch
has been merged with another utility (fsw
) and its behaviour has changed. The change is not backward-compatible and the major version number has been increased to give users a warning.
The new behaviour is printing change events to standard output so that users can pipe any process to fswatch
and process them as they like. This behaviour is more consistent with common UNIX practices and gives the user more flexibility.
The quickest way to update the scripts that rely on fswatch
is piping its output and execute the command you want to run:
fswatch -0 . | xargs -0 -n1 program-to-run
Please, have a look at Issue 20, where a discussion about this functional change took place.
Cheers,
-- Enrico M. Crisostomo
from fswatch.
Hi @emcrisostomo, thanks for answering. I blame homebrew that doesn't allow you to easily specify versions :(
I understand the appeal of unix tools, and use them a lot to my advantage, but the reason for choosing fswatch was it's simplicity for my use case (also involving rsync); adding 5-10 lines dealing with file events to an already complex ever-growing shell script is not something I'd like to do.
I'll be using spy in the meantime. Maybe a --run | --command
option can be added that also emits a single event per batch?
from fswatch.
Hi @ricardobeat,
You and your suggestions are welcome.
May I suggest you use xargs
, as suggested above? I guess that wouldn't add much complexity to your scripts:
fswatch -0 . | xargs -0 -n1 program-to-run
It's a bit more verbose, but way more powerful (one of the reasons I wanted fswatch events to be pipeable was filtering).
On the other hand, if the event detail is not important (as I infer from your suggestion about --run
), then I guess these are all votes for that feature, which is now the subject of Issue 20 and I'm going to implement the feature of emitting one single event per batch.
I'll leave this open for reference.
Thanks,
Enrico M. Crisostomo
from fswatch.
Awesome, thanks. Is there anything to be done to get the latest version on brew? I don't know how that process works.
from fswatch.
I was curious about this as well and I think the homebrew formula needs to be updated because it's hardcoded to pull release 1.3.2.
ref
Homebrew/legacy-homebrew@f8d9abb#diff-4b2a65915d48a425136a0b28970ccb47
from fswatch.
Neither do I, to say the truth. I Just forked Homebrew/homebrew
, updated the source tarball URL and checksum in the fswatch
formula and sent a pull request. Not sure whether this is the proper way to notify them, though.
from fswatch.
@emcrisostomo that's exactly the recommended process.
from fswatch.
Thank you very much @benesch.
from fswatch.
Related Issues (20)
- Universal (Arm + x86) library build for MacOS on M1 HOT 1
- Ask for help HOT 1
- import error in silicon mac
- Additional waiting period after --one-event
- Make fails on Solaris 11.4 cbe with gcc-10 or gcc-11
- Trailing slash for directories HOT 1
- CMake package config file is not installed
- fswatch fails to build on windows 11 using cygwin
- Installation for windows missing
- libfswatch README copyright looks stale
- Help configuring fswatch to act only on full file being written by SFTP clients HOT 1
- fswatch command fires multiple events for a single move operation HOT 4
- Which event type should I look for if I am watching a Google Drive directory for new files?
- NetBSD support
- Is there any way to get previous filename for Rename event?
- Symlink question: Is fswatch suppose to notify of linked file changes HOT 1
- execute cmd for single filetype
- fswatch is horribly slow on setting up inotify
- How to notify for write operations only? (using -m inotify_monitor on linux)
- Is this still being maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fswatch.