{"id":16934410,"url":"https://github.com/codeskyblue/fswatch","last_synced_at":"2025-04-06T10:11:49.139Z","repository":{"id":10898373,"uuid":"13192321","full_name":"codeskyblue/fswatch","owner":"codeskyblue","description":"Watch file change, and trigger commands. (Cross platform)","archived":false,"fork":false,"pushed_at":"2021-06-04T10:11:14.000Z","size":1816,"stargazers_count":347,"open_issues_count":3,"forks_count":59,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-30T08:12:20.921Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeskyblue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-29T12:53:28.000Z","updated_at":"2025-03-23T09:05:45.000Z","dependencies_parsed_at":"2022-08-30T10:50:22.909Z","dependency_job_id":null,"html_url":"https://github.com/codeskyblue/fswatch","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Ffswatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Ffswatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Ffswatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Ffswatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeskyblue","download_url":"https://codeload.github.com/codeskyblue/fswatch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247464222,"owners_count":20942970,"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-10-13T20:52:02.551Z","updated_at":"2025-04-06T10:11:49.116Z","avatar_url":"https://github.com/codeskyblue.png","language":"Go","funding_links":[],"categories":["\u003ca name=\"file-watch\"\u003e\u003c/a\u003eFile watching for changes","Go"],"sub_categories":[],"readme":"# fswatch\n[![Build Status](https://travis-ci.org/codeskyblue/fswatch.svg?branch=master)](https://travis-ci.org/codeskyblue/fswatch)\n[![Build status](https://ci.appveyor.com/api/projects/status/hble6an55u4a04e5/branch/master?svg=true)](https://ci.appveyor.com/project/codeskyblue/fswatch/branch/master)\n\n**fswatch** is a developer tool that triggers commands in response to filesystem changes.\nWorks well on Mac, Linux, and should also works on Windows(not well tested).\n\n## Install\n```\ngo get -u -v github.com/codeskyblue/fswatch\n```\n\n## Simple way to use fswatch\n\nUsage example\n\n```\n$ fswatch -v\n3.0\n$ fswtach --help\nshow help message ...\n```\n\nWatch file change event and trigger command\n\nTODO: now only watch `*.go, *.c, *.py` files, watch depth = 0 (current directory)\n\n```bash\n$ fswatch sh -c \"ls -l | wc -l\"\nfswatch \u003e\u003e\u003e [] exec start: sh -c 'ls -l | wc -l'\n       8\nfswatch \u003e\u003e\u003e [] finish in 11.822873ms\nfswatch \u003e\u003e\u003e changed: fswatch.go\nfswatch \u003e\u003e\u003e delay: 100ms\nfswatch \u003e\u003e\u003e [] exec start: [sh -c ls -l | wc -l]\n       8\nfswatch \u003e\u003e\u003e [] finish in 13.606428ms\n^Cfswatch \u003e\u003e\u003e Catch signal interrupt!\nfswatch \u003e\u003e\u003e Kill all running ... Done\n```\n\n## Hard way to use fswatch (not recommend)\n### Step 1\nCreate a config file `fsw.yml`\n\nconfig file example though command `fswatch` with no arguments\n\n```yaml\ndesc: Auto generated by fswatch [fswatch]\ntriggers:\n- pattens:\n  - '**/*.go'\n  - '**/*.c'\n  # also support '!**/test_*.go'\n  env:\n    DEBUG: \"1\"\n  # if shell is true, $cmd will be wrapped with `bash -c`\n  shell: true\n  cmd: go test -v\n  delay: 100ms\n  stop_timeout:1s\n  signal: \"KILL\"\n  kill_signal: \"SIGTERM\"\nwatch_paths:\n- .\nwatch_depth: 5\n```\n\n### Step 2\nRun `fswatch` directly.\nEvery time you edit a file. Command `go test -v` will be called.\n\n```\n$ fswatch\nfswatch \u003e\u003e\u003e exec start: go test -v\n# github.com/codeskyblue/fswatch\n./fswatch.go:281: main redeclared in this block\n\tprevious declaration at ./config.go:354\nfswatch \u003e\u003e\u003e program exited: exit status 2\nfswatch \u003e\u003e\u003e finish in 145.499911ms\n```\n\n\u003e support specify config file through `fswatch --config myfsw.yml`\n\n## You should know\n### How fswatch kill process\nfswatch send signal to all process when restart. (mac and linux killed by pgid, windows by taskkill)\n`Ctrl+C` will trigger fswatch quit and kill all process it started.\n\n### Pattens\nMore about the pattens. The patten has the same rule like `.gitignore`.\nSo you can write like this.\n\n```\n- pattens:\n  - '*.go'\n  - '!*_test.go'\n  - '!**/bindata.go'\n```\n\n`main.go` changed will trigger command, but `a_test.go` and `libs/bindata.go` will be ignored.\n\n## FAQs\n`too many open files`\n\nFor mac, run the following command\n\n    sysctl -w kern.maxfiles=20480\n    sysctl -w kern.maxfilesperproc=18000\n    ulimit -S -n 2048\n\n[reference](http://superuser.com/questions/433746/is-there-a-fix-for-the-too-many-open-files-in-system-error-on-os-x-10-7-1)\n\n## Other\n\n\nChinese Blog: \u003chttp://my.oschina.net/goskyblue/blog/194240\u003e\n\n## Friendly link: \n* [bee](https://github.com/astaxie/bee)\n* [fsnotify](github.com/go-fsnotify/fsnotify)\n* \u003chttps://github.com/codeskyblue/kexec\u003e\n* \u003chttps://github.com/codeskyblue/dockerignore\u003e\n\n## Code History\nI reviewed the first version of fswatch(which was taged 0.1). The code I look now is shit. So I deleted almost 80% code, And left some very useful functions.\n\n## Alternative\n* \u003chttps://github.com/cortesi/modd\u003e\n* \u003chttps://github.com/emcrisostomo/fswatch\u003e write with cpp\n* \u003chttps://github.com/Unknwon/bra\u003e Funny name.\n\n## LICENSE\nUnder [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Ffswatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeskyblue%2Ffswatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Ffswatch/lists"}