whatisgithub

What is fswatch?

emcrisostomo/fswatch — explained in plain English

Analysis updated 2026-06-26

5,532C++Audience · developerComplexity · 2/5LicenseSetup · easy

In one sentence

A command-line tool that watches files and folders and prints a notification whenever something changes, useful for automating tasks like rerunning build scripts whenever source files are edited.

Mindmap

mindmap
  root((fswatch))
    What it does
      File watcher
      Change notifications
      Cross platform
    Tech Stack
      C++
      inotify Linux
      FSEvents macOS
    Use Cases
      Auto rebuild
      Auto reload
      Trigger scripts
    Extras
      libfswatch library
      Recursive watching
      Pattern filtering
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Automatically rerun a build or test script whenever a source file changes in your project folder.

USE CASE 2

Trigger a deployment or reload step whenever a config file is modified on a server.

USE CASE 3

Embed file-watching capability in your own C or Go application using the included libfswatch library.

What is it built with?

C++CGo

How does it compare?

emcrisostomo/fswatchluau-lang/luaucinder/cinder
Stars5,5325,5285,525
LanguageC++C++C++
Setup difficultyeasyhardhard
Complexity2/54/54/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

Linux inotify backend does not detect changes made over a network or through certain low-level memory operations.

Open source and free to use in any project including commercial ones.

So what is it?

fswatch is a command-line tool that watches files and folders on your computer and tells you when anything changes. You point it at a file or directory, and it will print a notification every time that file is created, modified, deleted, or renamed. This makes it useful for building automated workflows, like automatically rerunning a script whenever a source file changes. One of the tool's main strengths is that it runs on many operating systems, including macOS, Linux, Windows, and various BSD-based systems. Rather than using a single approach everywhere, it picks the method that works best on each platform. On macOS it uses Apple's built-in file system events system. On Linux it uses a kernel feature called inotify. On Windows it uses a Windows API call. There is also a fallback method that works anywhere, which checks for changes by polling the file system on a schedule. fswatch supports watching entire directory trees recursively, so you do not need to list every subfolder separately. You can also filter which files trigger a notification using text patterns, so you could watch only files ending in a certain extension while ignoring others. The format of the output is configurable, meaning you can pipe it into other tools in custom ways. The project also ships a companion library called libfswatch, which developers can include in their own C, C++, or Go programs if they want to add file-watching capabilities directly to an application rather than calling the command-line tool. Each underlying monitoring method has trade-offs. The Linux inotify approach, for example, does not track changes made over a network or through certain low-level memory operations. The BSD kqueue approach opens a file descriptor for every file being watched, so it can run into system limits when monitoring a very large number of files. The README covers these limitations in detail so you can choose the right backend for your situation.

Copy-paste prompts

Prompt 1
How do I use fswatch to watch a folder and automatically run a shell script whenever any .js file changes?
Prompt 2
Set up fswatch on macOS to monitor a directory and restart a Node.js server every time a file changes.
Prompt 3
How do I filter fswatch to only notify me about changes to files with a specific extension while ignoring everything else?
Prompt 4
Explain the difference between fswatch backends such as FSEvents, inotify, kqueue, and poll, and which one I should use on Linux.

Frequently asked questions

What is fswatch?

A command-line tool that watches files and folders and prints a notification whenever something changes, useful for automating tasks like rerunning build scripts whenever source files are edited.

What language is fswatch written in?

Mainly C++. The stack also includes C++, C, Go.

What license does fswatch use?

Open source and free to use in any project including commercial ones.

How hard is fswatch to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is fswatch for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.