watch
for filesystem> watch {flags} (path) (closure)
--debounce-ms, -d {int}
: Debounce changes for this many milliseconds (default: 100). Adjust if you find that single writes are reported as multiple events--glob, -g {string}
: Only report changes for files that match this glob pattern (default: all files)--recursive, -r {bool}
: Watch all directories under <path>
recursively. Will be ignored if <path>
is a file (default: true)--verbose, -v
: Operate in verbose mode (default: false)path
: the path to watch. Can be a file or directoryclosure
: Some Nu code to run whenever a file changes. The closure will be passed operation
, path
, and new_path
(for renames only) arguments in that orderinput | output |
---|---|
nothing | table |
Run cargo test
whenever a Rust file changes
>watch.--glob=**/*.rs {|| cargotest }
Watch all changes in the current directory
>watch. { |op, path, new_path| $"($op) ($path) ($new_path)"}
Log all changes in a directory
>watch/foo/bar { |op, path| $"($op) - ($path)(char nl)"|save--appendchanges_in_bar.log }
Note: if you are looking to run a command every N units of time, this can be accomplished with a loop and sleep
>loop { command;sleepduration }
Copyright © 2019–2023 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/watch.html