{"id":13686866,"url":"https://github.com/tmc/watcher","last_synced_at":"2025-08-11T20:31:17.997Z","repository":{"id":4938326,"uuid":"6095208","full_name":"tmc/watcher","owner":"tmc","description":"watcher is a simple filesystem event watcher","archived":false,"fork":false,"pushed_at":"2022-02-24T18:44:38.000Z","size":17,"stargazers_count":71,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-02T20:49:59.704Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-05T19:08:20.000Z","updated_at":"2022-04-29T07:27:26.000Z","dependencies_parsed_at":"2022-08-18T02:45:20.922Z","dependency_job_id":null,"html_url":"https://github.com/tmc/watcher","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fwatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fwatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fwatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmc%2Fwatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmc","download_url":"https://codeload.github.com/tmc/watcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229586438,"owners_count":18096626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T15:00:42.160Z","updated_at":"2025-08-11T20:31:17.957Z","avatar_url":"https://github.com/tmc.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# watcher\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/tmc/watcher.svg)](https://pkg.go.dev/github.com/tmc/watcher)\n\nCommand watcher is a file watcher that executes a command when files change.\n\nIt can be used to automatically run tests, build code, or any other command when files in a directory change.\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003ePrerequisites: Go Installation\u003c/b\u003e\u003c/summary\u003e\n\nYou'll need Go 1.23 or later. [Install Go](https://go.dev/doc/install) if you haven't already.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eSetting up your PATH\u003c/b\u003e\u003c/summary\u003e\n\nAfter installing Go, ensure that `$HOME/go/bin` is in your PATH:\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eFor bash users\u003c/b\u003e\u003c/summary\u003e\n\nAdd to `~/.bashrc` or `~/.bash_profile`:\n```bash\nexport PATH=\"$PATH:$HOME/go/bin\"\n```\n\nThen reload your configuration:\n```bash\nsource ~/.bashrc\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eFor zsh users\u003c/b\u003e\u003c/summary\u003e\n\nAdd to `~/.zshrc`:\n```bash\nexport PATH=\"$PATH:$HOME/go/bin\"\n```\n\nThen reload your configuration:\n```bash\nsource ~/.zshrc\n```\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n\u003c/details\u003e\n\n### Install\n\n```console\ngo install github.com/tmc/watcher@latest\n```\n\n### Run directly\n\n```console\ngo run github.com/tmc/watcher@latest [arguments]\n```\n\n## Usage:\n\n\twatcher [flags] [command to execute and args]\n\n\t\t-c\tclear terminal before each run\n\t\t-depth int\n\t\t\trecursion depth (default 1)\n\t\t-dir string\n\t\t\tdirectory root to use for watching (default \".\")\n\t\t-ignore string\n\t\t\tcomma-separated list of glob patterns to ignore\n\t\t-quiet duration\n\t\t\tquiet period after command execution (default 800ms)\n\t\t-v\tverbose\n\t\t-wait duration\n\t\t\ttime to wait between change detection and exec (default 10ms)\n\n## Features\n\n  - Watch directories recursively with configurable depth\n  - Ignore files based on glob patterns (e.g., \\`-ignore \"\\*.tmp,\\*.log\"\\`)\n  - Automatically detects and watches newly created directories\n  - Graceful termination on SIGINT/SIGTERM\n  - Configurable quiet period to avoid rapid execution\n  - Configurable wait time between file change and command execution\n\n## Common Use Cases\n\n  - Run tests when source files change\n  - Trigger build steps in development\n  - Refresh browsers or servers\n  - Auto-compile code during development\n\n## Example Use:\n\nIn Shell A:\n\n```console\n\n$ go install github.com/tmc/watcher@latest\n$ mkdir /tmp/foo; cd /tmp/foo\n$ watcher -v echo \"triggered\"\nrunning echo triggered\ntriggered\n\n```\n\nNow, In Shell B:\n\n```console\n\n$ touch /tmp/foo/oi\n\n```\n\nEvery time /tmp/foo changes the echo will be re-executed.\n\nLicense: ISC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fwatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmc%2Fwatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmc%2Fwatcher/lists"}