Categorygithub.com/kbirk/witch
module
0.0.0-20240120040417-c6fe939a8d3c
Repository: https://github.com/kbirk/witch.git
Documentation: pkg.go.dev

# README

witch

Dead simple watching

Go Report Card

screenshot

Description

Detects changes to files or directories and executes the provided shell command. That's it.

Features:

  • Supports double-star globbing
  • Detects files / directories added after starting watch
  • Watch will persist if executed shell command returns an error (ex. compile / linting errors)
  • Awesome magic wand terminal spinner

Note: Uses polling to work consistently across multiple platforms, therefore the CPU usage is dependent on the efficiently of your globs. With a minimal effort your watch should use very little CPU. Will switch to event-based once fsnofity has matured sufficiently.

Dependencies

Requires the Go programming language binaries with the GOPATH environment variable specified and $GOPATH/bin in your PATH.

Installation

go get github.com/kbirk/witch

Usage

witch --cmd=<shell-command> [--watch="<glob>,..."] [--ignore="<glob>,..."] [--interval=<milliseconds>]

Command-line args:

FlagDescription
cmdShell command to execute after changes are detected
watchComma separated globs to watch (default: ".")
ignoreComma separated globs to ignore (default: "")
intervalScan interval in milliseconds (default: 400)
max-token-sizeMax output token size in bytes (default: 2048000)
no-spinnerDisable fancy terminal spinner (default: false)

Globbing

Globbing rules are the same as doublestar which supports the following special terms in the patterns:

Special TermsMeaning
*matches any sequence of non-path-separators
**matches any sequence of characters, including path separators
?matches any single non-path-separator character
[class]matches any single non-path-separator character against a class of characters (see below)
{alt1,...}matches a sequence of characters if one of the comma-separated alternatives matches

Any character with a special meaning can be escaped with a backslash (\).

Character Classes

Character classes support the following:

ClassMeaning
[abc]matches any single character within the set
[a-z]matches any single character in the range
[^class]matches any single character which does not match the class

Any globs resolved to a directory will be have all contents watched.

Example

witch --cmd="make lint && make fmt && make run" --watch="main.go,api/**/*.go"

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author