watchexec/doc/watchexec.1.html

187 lines
10 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta http-equiv='content-type' value='text/html;charset=utf8'>
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
<title>watchexec(1) - execute commands when watched files change</title>
<style type='text/css' media='all'>
/* style: man */
body#manpage {margin:0}
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
.mp h2 {margin:10px 0 0 0}
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
.mp h3 {margin:0 0 0 4ex}
.mp dt {margin:0;clear:left}
.mp dt.flush {float:left;width:8ex}
.mp dd {margin:0 0 0 9ex}
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
.mp pre {margin-bottom:20px}
.mp pre+h2,.mp pre+h3 {margin-top:22px}
.mp h2+pre,.mp h3+pre {margin-top:5px}
.mp img {display:block;margin:auto}
.mp h1.man-title {display:none}
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
.mp h2 {font-size:16px;line-height:1.25}
.mp h1 {font-size:20px;line-height:2}
.mp {text-align:justify;background:#fff}
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
.mp u {text-decoration:underline}
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
.mp b.man-ref {font-weight:normal;color:#434241}
.mp pre {padding:0 4ex}
.mp pre code {font-weight:normal;color:#434241}
.mp h2+pre,h3+pre {padding-left:0}
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
ol.man-decor {width:100%}
ol.man-decor li.tl {text-align:left}
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
ol.man-decor li.tr {text-align:right;float:right}
</style>
</head>
<!--
The following styles are deprecated and will be removed at some point:
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
.man-navigation should be used instead.
-->
<body id='manpage'>
<div class='mp' id='man'>
<div class='man-navigation' style='display:none'>
<a href="#NAME">NAME</a>
<a href="#SYNOPSIS">SYNOPSIS</a>
<a href="#DESCRIPTION">DESCRIPTION</a>
<a href="#OPTIONS">OPTIONS</a>
<a href="#ENVIRONMENT">ENVIRONMENT</a>
<a href="#EXAMPLES">EXAMPLES</a>
</div>
<ol class='man-decor man-head man head'>
<li class='tl'>watchexec(1)</li>
<li class='tc'></li>
<li class='tr'>watchexec(1)</li>
</ol>
<h2 id="NAME">NAME</h2>
<p class="man-name">
<code>watchexec</code> - <span class="man-whatis">execute commands when watched files change</span>
</p>
<h2 id="SYNOPSIS">SYNOPSIS</h2>
<p>watchexec [<code>--exts</code> | <code>-e</code> <var>extensions</var>]... [<code>--filter</code> | <code>-f</code> <var>pattern</var>]... [<code>--ignore</code> | <code>-i</code> <var>pattern</var>]... [<code>--watch</code> | <code>-w</code> <var>path</var>]... [<code>--restart</code> | <code>-r</code>] [<code>--clear</code> | <code>-c</code>] [<code>--postpone</code> | <code>-p</code>] [<code>--force-poll</code> <var>interval</var>] [<code>--debounce</code> | <code>-d</code> <var>interval</var>] [<code>--no-vcs-ignore</code>] [<code>--no-default-ignore</code>] [<code>--verbose</code> | <code>-v</code>] [<code>--changes-only</code>] [<code>--version</code> | <code>-V</code>] [--] <var>command</var> [<var>argument</var>...]</p>
<h2 id="DESCRIPTION">DESCRIPTION</h2>
<p>Recursively monitors the current directory for changes, executing the command when a filesystem change is detected. By default, watchexec uses efficient kernel-level mechanisms to watch for changes.</p>
<p>At startup, the specified <var>command</var> (passing any supplied <var>argument</var>s) is run once, and watchexec begins monitoring for changes.</p>
<h2 id="OPTIONS">OPTIONS</h2>
<dl>
<dt class="flush"><var>command</var></dt><dd><p>Command to run when watched files are modified, and at startup, unless <code>--postpone</code> is specified. All <var>argument</var>s are passed to <var>command</var>. If you pass flags to the command, you should separate it with <code>--</code>, for example: <code>watchexec -w src -- rsync -a src dest</code>.</p></dd>
<dt><code>-e</code>, <code>--exts</code> <var>extensions</var></dt><dd><p>Comma-separated list of file extensions to filter by. Leading dots (.rs) are allowed. (This is a shorthand for <code>-f</code>).</p></dd>
<dt><code>-f</code>, <code>--filter</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that do not match <var>pattern</var>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <var>command</var>.</p></dd>
<dt><code>-s</code>, <code>--signal</code></dt><dd><p>Sends the specified signal (e.g. <code>SIGKILL</code>) to the command. Defaults to <code>SIGTERM</code>.</p></dd>
<dt><code>--shell</code> <var>shell</var></dt><dd><p>Change the shell used to run the command. Set to <code>none</code> to run the command directly without a shell.</p></dd>
</dl>
<p>The special value <code>powershell</code> will use Microsoft Powershell's calling convention, otherwise <code>SHELL -c COMMAND</code>.</p>
<p>The <code>none</code> value is especially useful in combination with <code>--signal</code>, as the signal is then send directly to the specified command. While <code>--shell=none</code> is a little more performant than the default, it prevents using shell-features like pipes and redirects.</p>
<dl>
<dt><code>--no-shell</code></dt><dd><p>Deprecated. Alias for <code>--shell=none</code>.</p></dd>
<dt class="flush"><code>-n</code></dt><dd><p>Shorthand for <code>--shell=none</code>.</p></dd>
<dt><code>--no-meta</code></dt><dd><p>Ignore metadata changes.</p></dd>
<dt><code>--no-environment</code></dt><dd><p>Do not set WATCHEXEC<em>*</em>PATH environment variables for the command.</p></dd>
<dt><code>-i</code>, <code>--ignore</code> <var>pattern</var></dt><dd><p>Ignores modifications from paths that match <var>pattern</var>. This option can be specified multiple times, and a match on any pattern causes the path to be ignored.</p></dd>
<dt><code>-w</code>, <code>--watch</code> <var>path</var></dt><dd><p>Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes <var>command</var> to be executed.</p></dd>
<dt><code>-r</code>, <code>--restart</code></dt><dd><p>Terminates the command if it is still running when subsequent file modifications are detected. By default, sends <code>SIGTERM</code>; use <code>--signal</code> to change that.</p></dd>
<dt><code>-W</code>, <code>--watch-when-idle</code></dt><dd><p>Ignore events while the process is still running. This is distinct from <code>--restart</code> in that with this option, events received while the command is running will not trigger a new run immediately after the current command is done.</p></dd>
</dl>
<p>This behaviour will become the default in v2.0.</p>
<dl>
<dt><code>-c</code>, <code>--clear</code></dt><dd><p>Clears the screen before executing <var>command</var>.</p></dd>
<dt><code>-p</code>, <code>--postpone</code></dt><dd><p>Postpone execution of <var>command</var> until the first file modification is detected.</p></dd>
<dt><code>--force-poll</code> <var>interval</var></dt><dd><p>Poll for changes every <var>interval</var> ms instead of using system-specific notification mechanisms (such as inotify). This is useful when you are monitoring NFS shares.</p></dd>
<dt><code>-d</code>, <code>--debounce</code></dt><dd><p>Set the timeout between detected change and command execution, to avoid restarting too frequently when there are many events; defaults to 150ms.</p></dd>
<dt><code>--no-vcs-ignore</code></dt><dd><p>Skip loading of version control system (VCS) ignore files. By default, watchexec loads .gitignore files in the current directory (or parent directories) and uses them to populate the ignore list.</p></dd>
<dt><code>--no-default-ignore</code></dt><dd><p>Skip default ignore statements. By default, watchexec ignores common temporary files for you, for example <code>*.swp</code>, <code>*.pyc</code>, and <code>.DS_Store</code>.</p></dd>
<dt><code>-v</code>, <code>--verbose</code></dt><dd><p>Prints diagnostic messages to STDERR.</p></dd>
<dt><code>--changes-only</code></dt><dd><p>Prints the paths that have changed as diagnostics to STDERR, but not everything else that <code>--verbose</code> prints.</p></dd>
<dt><code>-V</code>, <code>--version</code></dt><dd><p>Print the version of watchexec.</p></dd>
<dt><code>-h</code>, <code>--help</code></dt><dd><p>Print a help message.</p></dd>
</dl>
<h2 id="ENVIRONMENT">ENVIRONMENT</h2>
<p>Processes started by watchexec have environment variables set describing the modification(s) observed. Which variable is set depends on how many modifications were observed and/or what type they were.</p>
<p>If a single file changed (depending on the event type):</p>
<ul>
<li><code>$WATCHEXEC_CREATED_PATH</code>, the path of the file that was created</li>
<li><code>$WATCHEXEC_REMOVED_PATH</code>, the path of the file that was removed</li>
<li><code>$WATCHEXEC_RENAMED_PATH</code>, the path of the file that was renamed</li>
<li><code>$WATCHEXEC_WRITTEN_PATH</code>, the path of the file that was modified</li>
<li><code>$WATCHEXEC_META_CHANGED_PATH</code>, the path of the file whose metadata changed</li>
</ul>
<p>If multiple files changed:</p>
<ul>
<li><code>$WATCHEXEC_COMMON_PATH</code>, the longest common path of all of the files that triggered a change</li>
</ul>
<h2 id="EXAMPLES">EXAMPLES</h2>
<p>Rebuild a project when source files change:</p>
<pre><code>$ watchexec make
</code></pre>
<p>Watch all HTML, CSS, and JavaScript files for changes:</p>
<pre><code>$ watchexec -e html,css,js make
</code></pre>
<p>Run tests when source files change, clearing the screen each time:</p>
<pre><code>$ watchexec -c make test
</code></pre>
<p>Launch and restart a node.js server:</p>
<pre><code>$ watchexec -r node app.js
</code></pre>
<p>Watch lib and src directories for changes, rebuilding each time:</p>
<pre><code>$ watchexec -w lib -w src make
</code></pre>
<ol class='man-decor man-foot man foot'>
<li class='tl'></li>
<li class='tc'>April 2021</li>
<li class='tr'>watchexec(1)</li>
</ol>
</div>
</body>
</html>