{"id":13392735,"url":"https://github.com/tj/watch","last_synced_at":"2025-04-05T08:03:45.651Z","repository":{"id":46040572,"uuid":"2950145","full_name":"tj/watch","owner":"tj","description":"watch(1) periodically executes the given command - useful for auto-testing, auto-building, auto-anything ","archived":false,"fork":false,"pushed_at":"2022-12-09T15:56:19.000Z","size":27,"stargazers_count":460,"open_issues_count":6,"forks_count":26,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-04-14T09:54:35.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tj.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-09T21:12:07.000Z","updated_at":"2024-03-30T15:09:04.000Z","dependencies_parsed_at":"2023-01-25T14:30:36.344Z","dependency_job_id":null,"html_url":"https://github.com/tj/watch","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Fwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Fwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Fwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tj%2Fwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tj","download_url":"https://codeload.github.com/tj/watch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305930,"owners_count":20917207,"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-07-30T17:00:36.292Z","updated_at":"2025-04-05T08:03:45.633Z","avatar_url":"https://github.com/tj.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"\n# Watch\n\n  A tiny C program used to periodically execute a command.\n\n## Usage\n\n```\n\nUsage: watch [options] \u003ccmd\u003e\n\nOptions:\n\n  -q, --quiet           only output stderr\n  -x, --halt            halt on failure\n  -i, --interval \u003cn\u003e    interval in seconds or ms defaulting to 1\n  -c, --clear           clear the screen between iterations\n  -v, --version         output version number\n  -h, --help            output this help information\n\n```\n\n## Installation\n\n```\n$ make install\n```\n\nOr in your local bin (`~/bin`)\n\n```\n$ PREFIX=~ make install\n```\n\n## About\n\n  This project is very similar to original [watch(1)](http://linux.die.net/man/1/watch) implemented in 1991, differences include:\n\n  - ansi escape sequences (colors etc)\n  - terminal is not cleared (unless `--clear` is provided)\n  - lower default interval of 1s\n  - millisecond interval resolution\n\n## Milliseconds resolution\n\n This version of `watch(1)` support millisecond resolution\n with the `ms` suffix:\n\n```\n$ watch -i 300ms echo hey\n```\n\nwhereas `300` would be seconds:\n\n```\n$ watch -i 300 echo hey\n```\n\n## Examples\n\n Watch is pretty handy, here are a few use-cases:\n\n### Running tests\n\n  Ad-hoc mtime watchers are annoying to construct,\n  and have relatively no purpose when you can simply\n  execute your tests at a regular interval. For example\n  run `watch(1)` as a job, running tests each second (or a \n  second after the program exits):\n\n```\n$ watch make test \u0026\n[1] 3794\n✔ bifs.components\n✔ bifs.dark\n✔ bifs.darken\n✔ bifs.image-size\n...\n```\n\n Your tests will happily chug away, when you want to\n stop watch simply foreground the job and ^C:\n \n```\n$ fg\n```\n\n### Auto-build CSS / JS etc\n\n Need to build CSS or JavaScript dependencies? use a _Makefile_. With the large quantity of copy-cats (Rake,Jake,Sake,Cake...) people seem to be forgetting that Make is awesome, if you take a little bit of time to learn it you'll love it (or at least most of it). Make will utilize `mtime` and only build what's necessary, this is _great_.\n\n Let's say we had some Jade templates, even some nested in sub-directories, we could list them in a _Makefile_ quite easily.\n \n Below __JADE__ is a list constructed by the shell command `find templates -name \"*.jade\"`, which is usually a lot easier to manage than listing these files manually, which is also valid, and sometimes important of ordering is relevant. Following that we have __HTML__ which simply substitutes \".jade\" with \".html\", giving us our HTML targets. \n\n```make\nJADE = $(shell find templates -name \"*.jade\")\nHTML = $(JADE:.jade=.html)\n```\n\n Our first target is `all`, becoming the default target for `make`. On the right-hand side of this we specify the dependencies, which in this case is a list of all of our HTML files, not yet built. Make will see this and execute the `%.html` targets, which allows use to use the `jade(1)` executable to translate the dependency on the right of `:`, to the target on the left. \n\n```make\nJADE = $(shell find templates -name \"*.jade\")\nHTML = $(JADE:.jade=.html)\n\nall: $(HTML)\n\n%.html: %.jade\n\tjade \u003c $\u003c \u003e $@\n```\n\n Now we can build all of these files with a single command `make`:\n\n```\n$ make\njade \u003c templates/bar.jade \u003e templates/bar.html\njade \u003c templates/baz/raz.jade \u003e templates/baz/raz.html\njade \u003c templates/foo.jade \u003e templates/foo.html\n```\n\n We can also add a `clean` pseudo-target to remove the compiled files with `make clean`. Here it's listed to the right of `.PHONY:`, telling make that it does not expect a file named `./clean` on the fs, so it wont compare mtimes etc. Make is smart about re-executing these actions, if you `make` again you'll notice that since none of the dependencies have changed it'll simply tell you \"make: Nothing to be done for `all'.\".\n\n```make\nJADE = $(shell find templates -name \"*.jade\")\nHTML = $(JADE:.jade=.html)\n\nall: $(HTML)\n\n%.html: %.jade\n\tjade \u003c $\u003c \u003e $@\n\nclean:\n\trm -f $(HTML)\n\n.PHONY: clean\n```\n\n  The one missing component is periodical action, which is where `watch(1)` or similar utilities come in, this functionality coupled with Make as a build system creates a powerful duo. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Fwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftj%2Fwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftj%2Fwatch/lists"}