{"id":24844574,"url":"https://github.com/jtyers/ww","last_synced_at":"2025-08-23T02:33:21.009Z","repository":{"id":109431749,"uuid":"239474718","full_name":"jtyers/ww","owner":"jtyers","description":"ww - a better watch, with highlighting, watching local files, and shell alias compatibility","archived":false,"fork":false,"pushed_at":"2024-04-10T08:20:22.000Z","size":293,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T09:24:15.421Z","etag":null,"topics":["cli","command-line","command-line-tool","linux-shell","shell","shell-scripting","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/jtyers.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-10T09:36:05.000Z","updated_at":"2024-09-10T21:04:52.000Z","dependencies_parsed_at":"2023-03-22T09:33:09.942Z","dependency_job_id":null,"html_url":"https://github.com/jtyers/ww","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/jtyers/ww","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyers%2Fww","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyers%2Fww/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyers%2Fww/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyers%2Fww/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jtyers","download_url":"https://codeload.github.com/jtyers/ww/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jtyers%2Fww/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271732426,"owners_count":24811324,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","command-line","command-line-tool","linux-shell","shell","shell-scripting","zsh"],"created_at":"2025-01-31T09:30:56.365Z","updated_at":"2025-08-23T02:33:20.998Z","avatar_url":"https://github.com/jtyers.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ww - a better `watch`\n\n![ww in action](demo.gif)\n\n`watch` has been part of the furniture on Linux/UNIX for years. A classic example of a simple concept, implemented simply and elegantly.\n\nBut...  it could benefit from a few extra features to make it even better. `ww` began as a block in my shell config but I've now spit it out here to share with others.  `ww` brings you `watch` as you know, but with some extras:\n\n* use `ww` in scripts to wait for some condition to succeed before carrying on\n\n* supports watching shell aliases, and even pipelines\n\n* countdown number of seconds left before next execution\n\n* watch for changes to files rather than running on an interval\n\n* coloured bar along the top to clearly indicate success/failure\n\n* highlight particular words in the output\n\n* watch a command until it succeeds, then exit (handy for scripting, eg ensuring a host is responding to pings before SSHing to it)\n\n## Installation\n\n1. Clone this repository:\n\n```\n# change ~/ww to where you want to clone\ngit clone https://github.com/jtyers/ww.git ~/ww\n```\n\n2. Add this to `~/.zshrc`:\n\n```\n# replace path here with wherever you checked out this repo\nsource ~/ww/ww\n```\n\n## How to use\n\nRun `cmd` every 3 seconds. If you omit `-n`, it defaults to `10`. `cmd` can be a shell alias or any pipeline, making it rather powerful if you need to run your own aliases over the top.\n\n```\nww -n 3 cmd\n```\n\nRun `kubectl get pods | grep foo-bar` every 3 seconds until it succeeds, then quit.\n\n```\n# notice that the pipe character should be escaped\nww -n 3 --until -- kubectl get pods \\| grep foo-bar\n\n# or include it in quotes\nww -n 3 --until -- \"kubectl get pods | grep foo-bar\"\n\n```\n\nRun `npm run test`, and re-run if any files in the current directory are written to, renamed or deleted. This uses `inotify` under the hood currently, so only supports Linux, and may be slow in larger directory hierarchies.\n\n```\nww -w npm run test\n```\n\nRun `tail log.txt`, and re-run any time files in the current directory are changed. Highlight instances of \"error\" and \"fail\" in the output. Repeat `-c \u003cword\u003e` to add more words. Highlighting is case-insensitive.\n\n```\nww -w -c error -c fail tail log.txt\n```\n\nIf you need to pass arguments to `cmd`, be sure to use `--` so that `ww` doesn't gobble them up. For example:\n\n```\nww -n 5 -- df -h\n```\n\nUse `WW_DEFAULT_ARGS` to set default arguments. For example:\n```\nexport WW_DEFAULT_ARGS=\"-c err -c fail\"\n\n# ww will now always highlight \"err\" and \"fail\" in output\nww my-command\n```\n\nFor maximum ease of use, I define these aliases to run `ww` in various forms quickly:\n```\nalias www='ww -w'\nalias ww2='ww -n2'\nalias ww5='ww -n5'\nalias wwu='ww --until'\n```\n\n## Usage\n\n```\nww - a better watch\n\nUSAGE\n  ww [opts] [--] CMD\n\n  --once, -1\n    quit after CMD finishes successfully (exit code 0)\n\n  --color, --colour, -c WORD\n    highlight instances of WORD in output (can be repeated)\n\n  --interval, -n N\n    refresh every N seconds (ignored if -w is specified)\n\n  --watch, -w\n    refresh when files in the current directory are changed\n    (requires inotifywatch to be installed)\n\n  --watch-wait, -W SECONDS\n    when --watch is used, ww will wait a short period after a\n    change is detected to allow related I/O operations to complete\n    (default: 0.25)\n\n  --no-capture, -n\n    allow underlying command to print straight to terminal rather\n    than capturing output (used for slower commands, such as find,\n    tail -f, etc; in this mode, --color has no effect)\n\n  --until, -u\n    wait until CMD has run successfully, then quit (this is just an\n    alias for '--no-capture --once')\n\n  --quiet, -q\n    suppress output (both of ww and CMD; only affects standard output of CMD,\n    any errors are still printed)\n\nIf WW_DEFAULT_ARGS is set, this can contain default arguments, processed before command line arguments on every invocation.\n\nYou can use any shell expansions or aliases in CMD, but remember to escape special characters (see EXAMPLES below).\n\nExamples:\n  # run ls every 10 seconds\n  ww ls\n\n  # when CMD includes arguments either use '--' or quote CMD\n\n  ww 'df -h'    # run df -h every 10 seconds\n  ww -- df -h   # equivalent to above\n\n  # run 'go test' every 2 seconds, grepping for FAILED \n  # (note the escaped pipe character)\n  ww -n 2 go test \\| grep FAILED\n  \n  # run 'go test' every time files in the current directory\n  # are changed\n  ww -w go test\n  \n  # run 'ls ~/foo' continuously, if it fails, retry after 5 seconds, exit when it succeeds\n  ww -u -n 5 ls ~/foo\n  \n  # silently wait for ls ~/foo to succeed, and then exit\n  ww -n 2 -qu ls ~/foo\n  \n  # silently wait for PID 100 to disappear, then exit (works since we can execute any shell code as an argument)\n  ww -n 2 -qu '[ -z \"$(ps -hp 1)\" ]'\n\n```\n\n`ww` works with `zsh`, tested on v5.7.1. Should work with any POSIX-compatible shell, though I haven't tested in other shells. Feedback and PRs welcome!\n\n\n## Contributing\n\nContributions are very welcome, please raise a PR and state clearly what problem you're trying to solve. Keep in mind that `ww` is designed to be light and fast.\n\n## Licence\n\nThis is open-sourced under the MIT licence. See the LICENCE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyers%2Fww","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjtyers%2Fww","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjtyers%2Fww/lists"}