1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
<!DOCTYPE html>
<html lang="en" data-content_root="../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>complete - edit command-specific tab-completions — fish-shell 4.2.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=4da8bbd6" />
<link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=f89b4716" />
<script src="../_static/documentation_options.js?v=6fb65176"></script>
<script src="../_static/doctools.js?v=9bcbadda"></script>
<script src="../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="contains - test if a word is present in a list" href="contains.html" />
<link rel="prev" title="commandline - set or get the current command line buffer" href="commandline.html" />
<link rel="shortcut icon" type="image/png" href="../_static/fish.png" />
</head><body><div id="fmain">
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li><img src="../_static/fish.png" alt=""
style="width: 80px; height: 80px; vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://fishshell.com/">fish-shell</a> »</li>
<a href="../index.html">fish-shell 4.2.1 documentation</a> »
<li class="nav-item nav-item-1"><a href="../commands.html" accesskey="U">Commands</a> »</li>
<li class="nav-item nav-item-this"><a href="">complete - edit command-specific tab-completions</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</li>
<div id="old-docs-notice" style="display: none">
This documents an old version of fish.
<a href="../../current/">See the latest release.</a>
</div>
</ul>
</div>
<div class="document">
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<div>
<h3><a href="../index.html">Documents</a></h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq.html">Frequently asked questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../interactive.html">Interactive use</a></li>
<li class="toctree-l1"><a class="reference internal" href="../language.html">The fish language</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../commands.html">Commands</a></li>
<li class="toctree-l1"><a class="reference internal" href="../fish_for_bash_users.html">Fish for bash users</a></li>
<li class="toctree-l1"><a class="reference internal" href="../tutorial.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../completions.html">Writing your own completions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../prompt.html">Writing your own prompt</a></li>
<li class="toctree-l1"><a class="reference internal" href="../design.html">Design</a></li>
<li class="toctree-l1"><a class="reference internal" href="../relnotes.html">Release notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="../terminal-compatibility.html">Terminal Compatibility</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contributing.html">Contributing To Fish</a></li>
<li class="toctree-l1"><a class="reference internal" href="../license.html">License</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
<div>
<h4><a href="../index.html">Sections</a></h4>
<ul>
<li><a class="reference internal" href="#">complete - edit command-specific tab-completions</a><ul>
<li><a class="reference internal" href="#synopsis">Synopsis</a></li>
<li><a class="reference internal" href="#description">Description</a></li>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="complete-edit-command-specific-tab-completions">
<h1>complete - edit command-specific tab-completions<a class="headerlink" href="#complete-edit-command-specific-tab-completions" title="Link to this heading">¶</a></h1>
<section id="synopsis">
<h2>Synopsis<a class="headerlink" href="#synopsis" title="Link to this heading">¶</a></h2>
<div class="highlight-fish-synopsis notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="g g-Other">((</span><span class="no">-c</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--command</span><span class="g g-Other">)</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="g g-Other">(</span><span class="no">-p</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--path</span><span class="g g-Other">))</span><span class="w"> </span><span class="no">COMMAND</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">OPTIONS</span><span class="g g-Other">]</span>
<span class="nf">complete</span><span class="w"> </span><span class="g g-Other">(</span><span class="no">-C</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--do-complete</span><span class="g g-Other">)</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">--escape</span><span class="g g-Other">]</span><span class="w"> </span><span class="no">STRING</span>
</pre></div>
</div>
</section>
<section id="description">
<h2>Description<a class="headerlink" href="#description" title="Link to this heading">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">complete</span></code> defines, removes or lists completions for a command.</p>
<p>For an introduction to writing your own completions, see <a class="reference internal" href="../completions.html"><span class="doc">Writing your own completions</span></a> in
the fish manual.</p>
<p>The following options are available:</p>
<dl class="simple">
<dt><strong>-c</strong> or <strong>--command</strong> <em>COMMAND</em></dt><dd><p>Specifies that <em>COMMAND</em> is the name of the command. If there is no <strong>-c</strong> or <strong>-p</strong>, one non-option argument will be used as the command.</p>
</dd>
<dt><strong>-p</strong> or <strong>--path</strong> <em>COMMAND</em></dt><dd><p>Specifies that <em>COMMAND</em> is the absolute path of the command (optionally containing wildcards).</p>
</dd>
<dt><strong>-e</strong> or <strong>--erase</strong></dt><dd><p>Deletes the specified completion.</p>
</dd>
<dt><strong>-s</strong> or <strong>--short-option</strong> <em>SHORT_OPTION</em></dt><dd><p>Adds a short option to the completions list.</p>
</dd>
<dt><strong>-l</strong> or <strong>--long-option</strong> <em>LONG_OPTION</em></dt><dd><p>Adds a GNU-style long option to the completions list.</p>
</dd>
<dt><strong>-o</strong> or <strong>--old-option</strong> <em>OPTION</em></dt><dd><p>Adds an old-style short or long option (see below for details).</p>
</dd>
<dt><strong>-a</strong> or <strong>--arguments</strong> <em>ARGUMENTS</em></dt><dd><p>Adds the specified option arguments to the completions list.</p>
</dd>
<dt><strong>-k</strong> or <strong>--keep-order</strong></dt><dd><p>Keeps the order of <em>ARGUMENTS</em> instead of sorting alphabetically. Multiple <code class="docutils literal notranslate"><span class="pre">complete</span></code> calls with <strong>-k</strong> result in arguments of the later ones displayed first.</p>
</dd>
<dt><strong>-f</strong> or <strong>--no-files</strong></dt><dd><p>This completion may not be followed by a filename.</p>
</dd>
<dt><strong>-F</strong> or <strong>--force-files</strong></dt><dd><p>This completion may be followed by a filename, even if another applicable <code class="docutils literal notranslate"><span class="pre">complete</span></code> specified <strong>--no-files</strong>.</p>
</dd>
<dt><strong>-r</strong> or <strong>--require-parameter</strong></dt><dd><p>This completion must have an option argument, i.e. may not be followed by another option.
This means that the next argument is the argument to the option.
If this is <em>not</em> given, the option argument must be attached like <code class="docutils literal notranslate"><span class="pre">-xFoo</span></code> or <code class="docutils literal notranslate"><span class="pre">--color=auto</span></code>.</p>
</dd>
<dt><strong>-x</strong> or <strong>--exclusive</strong></dt><dd><p>Short for <strong>-r</strong> and <strong>-f</strong>.</p>
</dd>
<dt><strong>-d</strong> or <strong>--description</strong> <em>DESCRIPTION</em></dt><dd><p>Add a description for this completion, to be shown in the completion pager.</p>
</dd>
<dt><strong>-w</strong> or <strong>--wraps</strong> <em>WRAPPED_COMMAND</em></dt><dd><p>Causes the specified command to inherit completions from <em>WRAPPED_COMMAND</em>.
This is used for “this command completes like that other command” kinds of relationships.
See below for details.</p>
</dd>
<dt><strong>-n</strong> or <strong>--condition</strong> <em>CONDITION</em></dt><dd><p>This completion should only be used if the <em>CONDITION</em> (a shell command) returns 0. This makes it possible to specify completions that should only be used in some cases. If multiple conditions are specified, fish will try them in the order they are specified until one fails or all succeeded.</p>
</dd>
<dt><strong>-C</strong> or <strong>--do-complete</strong> <em>STRING</em></dt><dd><p>Makes <code class="docutils literal notranslate"><span class="pre">complete</span></code> try to find all possible completions for the specified string. If there is no <em>STRING</em>, the current commandline is used instead.</p>
</dd>
<dt><strong>--escape</strong></dt><dd><p>When used with <code class="docutils literal notranslate"><span class="pre">-C</span></code>, escape special characters in completions.</p>
</dd>
<dt><strong>-h</strong> or <strong>--help</strong></dt><dd><p>Displays help about using this command.</p>
</dd>
</dl>
<p>Command-specific tab-completions in <code class="docutils literal notranslate"><span class="pre">fish</span></code> are based on the notion of options and arguments. An option is a parameter which begins with a hyphen, such as <code class="docutils literal notranslate"><span class="pre">-h</span></code>, <code class="docutils literal notranslate"><span class="pre">-help</span></code> or <code class="docutils literal notranslate"><span class="pre">--help</span></code>. Arguments are parameters that do not begin with a hyphen. Fish recognizes three styles of options, the same styles as the GNU getopt library. These styles are:</p>
<ul class="simple">
<li><p>Short options, like <code class="docutils literal notranslate"><span class="pre">-a</span></code>. Short options are a single character long, are preceded by a single hyphen and can be grouped together (like <code class="docutils literal notranslate"><span class="pre">-la</span></code>, which is equivalent to <code class="docutils literal notranslate"><span class="pre">-l</span> <span class="pre">-a</span></code>). Option arguments may be specified by appending the option with the value (<code class="docutils literal notranslate"><span class="pre">-w32</span></code>), or, if <code class="docutils literal notranslate"><span class="pre">--require-parameter</span></code> is given, in the following parameter (<code class="docutils literal notranslate"><span class="pre">-w</span> <span class="pre">32</span></code>).</p></li>
<li><p>Old-style options, long like <code class="docutils literal notranslate"><span class="pre">-Wall</span></code> or <code class="docutils literal notranslate"><span class="pre">-name</span></code> or even short like <code class="docutils literal notranslate"><span class="pre">-a</span></code>. Old-style options can be more than one character long, are preceded by a single hyphen and may not be grouped together. Option arguments are specified by default following a space (<code class="docutils literal notranslate"><span class="pre">-foo</span> <span class="pre">null</span></code>) or after <code class="docutils literal notranslate"><span class="pre">=</span></code> (<code class="docutils literal notranslate"><span class="pre">-foo=null</span></code>).</p></li>
<li><p>GNU-style long options, like <code class="docutils literal notranslate"><span class="pre">--colors</span></code>. GNU-style long options can be more than one character long, are preceded by two hyphens, and can’t be grouped together. Option arguments may be specified after a <code class="docutils literal notranslate"><span class="pre">=</span></code> (<code class="docutils literal notranslate"><span class="pre">--quoting-style=shell</span></code>), or, if <code class="docutils literal notranslate"><span class="pre">--require-parameter</span></code> is given, in the following parameter (<code class="docutils literal notranslate"><span class="pre">--quoting-style</span> <span class="pre">shell</span></code>).</p></li>
</ul>
<p>Multiple commands and paths can be given in one call to define the same completions for multiple commands.</p>
<p>Multiple command switches and wrapped commands can also be given to define multiple completions in one call.</p>
<p>Invoking <code class="docutils literal notranslate"><span class="pre">complete</span></code> multiple times for the same command adds the new definitions on top of any existing completions defined for the command.</p>
<p>When <code class="docutils literal notranslate"><span class="pre">-a</span></code> or <code class="docutils literal notranslate"><span class="pre">--arguments</span></code> is specified in conjunction with long, short, or old-style options, the specified arguments are only completed as arguments for any of the specified options. If <code class="docutils literal notranslate"><span class="pre">-a</span></code> or <code class="docutils literal notranslate"><span class="pre">--arguments</span></code> is specified without any long, short, or old-style options, the specified arguments are used when completing non-option arguments to the command (except when completing an option argument that was specified with <code class="docutils literal notranslate"><span class="pre">-r</span></code> or <code class="docutils literal notranslate"><span class="pre">--require-parameter</span></code>).</p>
<p>Command substitutions found in <code class="docutils literal notranslate"><span class="pre">ARGUMENTS</span></code> should return a newline-separated list of arguments, and each argument may optionally have a tab character followed by the argument description. Description given this way override a description given with <code class="docutils literal notranslate"><span class="pre">-d</span></code> or <code class="docutils literal notranslate"><span class="pre">--description</span></code>.</p>
<p>Descriptions given with <code class="docutils literal notranslate"><span class="pre">--description</span></code> are also used to group options given with <code class="docutils literal notranslate"><span class="pre">-s</span></code>, <code class="docutils literal notranslate"><span class="pre">-o</span></code> or <code class="docutils literal notranslate"><span class="pre">-l</span></code>. Options with the same (non-empty) description will be listed as one candidate, and one of them will be picked. If the description is empty or no description was given this is skipped.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">-w</span></code> or <code class="docutils literal notranslate"><span class="pre">--wraps</span></code> options causes the specified command to inherit completions from another command, “wrapping” the other command. The wrapping command can also have additional completions. A command can wrap multiple commands, and wrapping is transitive: if A wraps B, and B wraps C, then A automatically inherits all of C’s completions. Wrapping can be removed using the <code class="docutils literal notranslate"><span class="pre">-e</span></code> or <code class="docutils literal notranslate"><span class="pre">--erase</span></code> options. Wrapping only works for completions specified with <code class="docutils literal notranslate"><span class="pre">-c</span></code> or <code class="docutils literal notranslate"><span class="pre">--command</span></code> and are ignored when specifying completions with <code class="docutils literal notranslate"><span class="pre">-p</span></code> or <code class="docutils literal notranslate"><span class="pre">--path</span></code>.</p>
<p>When erasing completions, it is possible to either erase all completions for a specific command by specifying <code class="docutils literal notranslate"><span class="pre">complete</span> <span class="pre">-c</span> <span class="pre">COMMAND</span> <span class="pre">-e</span></code>, or by specifying a specific completion option to delete.</p>
<p>When <code class="docutils literal notranslate"><span class="pre">complete</span></code> is called without anything that would define or erase completions (options, arguments, wrapping, …), it shows matching completions instead. So <code class="docutils literal notranslate"><span class="pre">complete</span></code> without any arguments shows all loaded completions, <code class="docutils literal notranslate"><span class="pre">complete</span> <span class="pre">-c</span> <span class="pre">foo</span></code> shows all loaded completions for <code class="docutils literal notranslate"><span class="pre">foo</span></code>. Since completions are <a class="reference internal" href="../language.html#syntax-function-autoloading"><span class="std std-ref">autoloaded</span></a>, you will have to trigger them first.</p>
</section>
<section id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Link to this heading">¶</a></h2>
<p>The short-style option <code class="docutils literal notranslate"><span class="pre">-o</span></code> for the <code class="docutils literal notranslate"><span class="pre">gcc</span></code> command needs a file argument:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">gcc</span><span class="w"> </span><span class="no">-s</span><span class="w"> </span><span class="no">o</span><span class="w"> </span><span class="no">-r</span>
</pre></div>
</div>
<p>The short-style option <code class="docutils literal notranslate"><span class="pre">-d</span></code> for the <code class="docutils literal notranslate"><span class="pre">grep</span></code> command requires one of <code class="docutils literal notranslate"><span class="pre">read</span></code>, <code class="docutils literal notranslate"><span class="pre">skip</span></code> or <code class="docutils literal notranslate"><span class="pre">recurse</span></code>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">grep</span><span class="w"> </span><span class="no">-s</span><span class="w"> </span><span class="no">d</span><span class="w"> </span><span class="no">-x</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="s2">"read skip recurse"</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">su</span></code> command takes any username as an argument. Usernames are given as the first colon-separated field in the file /etc/passwd. This can be specified as:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-x</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">su</span><span class="w"> </span><span class="no">-d</span><span class="w"> </span><span class="s2">"Username"</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="s2">"(cat /etc/passwd | cut -d : -f 1)"</span>
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">rpm</span></code> command has several different modes. If the <code class="docutils literal notranslate"><span class="pre">-e</span></code> or <code class="docutils literal notranslate"><span class="pre">--erase</span></code> flag has been specified, <code class="docutils literal notranslate"><span class="pre">rpm</span></code> should delete one or more packages, in which case several switches related to deleting packages are valid, like the <code class="docutils literal notranslate"><span class="pre">nodeps</span></code> switch.</p>
<p>This can be written as:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">rpm</span><span class="w"> </span><span class="no">-n</span><span class="w"> </span><span class="s2">"__fish_contains_opt -s e erase"</span><span class="w"> </span><span class="no">-l</span><span class="w"> </span><span class="no">nodeps</span><span class="w"> </span><span class="no">-d</span><span class="w"> </span><span class="s2">"Don't check dependencies"</span>
</pre></div>
</div>
<p>where <code class="docutils literal notranslate"><span class="pre">__fish_contains_opt</span></code> is a function that checks the command line buffer for the presence of a specified set of options.</p>
<p>To implement an alias, use the <code class="docutils literal notranslate"><span class="pre">-w</span></code> or <code class="docutils literal notranslate"><span class="pre">--wraps</span></code> option:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">hub</span><span class="w"> </span><span class="no">-w</span><span class="w"> </span><span class="no">git</span>
</pre></div>
</div>
<p>Now hub inherits all of the completions from git. Note this can also be specified in a function declaration (<code class="docutils literal notranslate"><span class="pre">function</span> <span class="pre">thing</span> <span class="pre">-w</span> <span class="pre">otherthing</span></code>).</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">complete</span><span class="w"> </span><span class="no">-c</span><span class="w"> </span><span class="no">git</span>
</pre></div>
</div>
<p>Shows all completions for <code class="docutils literal notranslate"><span class="pre">git</span></code>.</p>
<p>Any command <code class="docutils literal notranslate"><span class="pre">foo</span></code> that doesn’t support grouping multiple short options in one string (not supporting <code class="docutils literal notranslate"><span class="pre">-xf</span></code> as short for <code class="docutils literal notranslate"><span class="pre">-x</span> <span class="pre">-f</span></code>) or a short option and its value in one string (not supporting <code class="docutils literal notranslate"><span class="pre">-d9</span></code> instead of <code class="docutils literal notranslate"><span class="pre">-d</span> <span class="pre">9</span></code>) should be specified as a single-character old-style option instead of as a short-style option; for example, <code class="docutils literal notranslate"><span class="pre">complete</span> <span class="pre">-c</span> <span class="pre">foo</span> <span class="pre">-o</span> <span class="pre">s;</span> <span class="pre">complete</span> <span class="pre">-c</span> <span class="pre">foo</span> <span class="pre">-o</span> <span class="pre">v</span></code> would never suggest <code class="docutils literal notranslate"><span class="pre">foo</span> <span class="pre">-ov</span></code> but rather <code class="docutils literal notranslate"><span class="pre">foo</span> <span class="pre">-o</span> <span class="pre">-v</span></code>.</p>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li><img src="../_static/fish.png" alt=""
style="width: 80px; height: 80px; vertical-align: middle; margin-top: -1px"/></li>
<li><a href="https://fishshell.com/">fish-shell</a> »</li>
<a href="../index.html">fish-shell 4.2.1 documentation</a> »
<li class="nav-item nav-item-1"><a href="../commands.html" >Commands</a> »</li>
<li class="nav-item nav-item-this"><a href="">complete - edit command-specific tab-completions</a></li>
<li class="right">
<div class="inline-search" role="search">
<form class="inline-search" action="../search.html" method="get">
<input placeholder="Quick search" type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</li>
<div id="old-docs-notice" style="display: none">
This documents an old version of fish.
<a href="../../current/">See the latest release.</a>
</div>
</ul>
</div>
<div class="footer">
© Copyright fish-shell developers.
<br />
<a href="https://github.com/fish-shell/fish-shell/issues">Found a bug</a>?
<br />
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
</div>
</div>
<script type="text/javascript">
FISH_DOCS_VERSION = "4.2";
function copy_to_clipboard(it) {
// Find the pre tag we're interested in.
var pre = it.target;
while (pre.tagName != "PRE") pre = pre.parentNode;
var txt = "";
// Cheesy: If we have a prompt,
// we only copy prompted lines,
// by splitting and matching and stuff
if (pre.querySelector('span.gp')) {
var texts= [];
for (var line of pre.innerText.split('\n')) {
if (line.match(/^>_?.*/)) {
texts.push(line.replace(/^>_?/, ""));
}
}
txt = texts.join("\n");
} else {
// Even cheesier: If we don't have a prompt, we remove the button text from the end.
var txt = pre.innerText.substring(0, pre.innerText.length - it.target.innerText.length).trim();
}
navigator.clipboard.writeText(txt).then(function() {
// Success - set the text to indicate it,
// then set it back after 2 seconds.
var span = pre.querySelector("button span");
if (span) {
var oldText = span.innerText;
span.innerText = "COPIED!";
setTimeout(function() {
span.innerText = oldText;
}, 2000);
}
}, function() {
});
}
(function () {
// Add copy buttons to all the codeblocks.
var codeblocks = document.querySelectorAll('div > pre');
var button = document.createElement('button');
var span = document.createElement('span');
span.innerText = "COPY";
button.appendChild(span);
for (var i of codeblocks) {
var newButton = button.cloneNode(true);
newButton.addEventListener('click', copy_to_clipboard);
i.appendChild(newButton);
}
})();
</script>
</body>
</html>
|