File: abbr.html

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (347 lines) | stat: -rw-r--r-- 32,130 bytes parent folder | download
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
<!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>abbr - manage fish abbreviations &#8212; 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="alias - create a function" href="alias.html" />
    <link rel="prev" title="_ - call fish’s translations" href="_.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> &#187;</li>
    
    <a href="../index.html">fish-shell 4.2.1 documentation</a> &#187;
    

          <li class="nav-item nav-item-1"><a href="../commands.html" accesskey="U">Commands</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">abbr - manage fish abbreviations</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="#">abbr - manage fish abbreviations</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="#add-subcommand">“add” subcommand</a><ul>
<li><a class="reference internal" href="#examples">Examples</a></li>
</ul>
</li>
<li><a class="reference internal" href="#other-subcommands">Other subcommands</a></li>
</ul>
</li>
</ul>

</div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="abbr-manage-fish-abbreviations">
<h1>abbr - manage fish abbreviations<a class="headerlink" href="#abbr-manage-fish-abbreviations" 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">abbr</span><span class="w"> </span><span class="no">--add</span><span class="w"> </span><span class="no">NAME</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">--position</span><span class="w"> </span><span class="no">command</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">anywhere</span><span class="g g-Other">]</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">-r</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--regex</span><span class="w"> </span><span class="no">PATTERN</span><span class="g g-Other">]</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="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="no">--set-cursor</span><span class="g g-Other">[</span><span class="no">=MARKER</span><span class="g g-Other">]]</span><span class="w"> </span><span class="g g-Other">([</span><span class="no">-f</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--function</span><span class="w"> </span><span class="no">FUNCTION</span><span class="g g-Other">]</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">EXPANSION</span><span class="g g-Other">)</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--erase</span><span class="w"> </span><span class="no">[ </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="w"> </span><span class="no">COMMAND</span><span class="g g-Other">]...</span><span class="no"> ]</span><span class="w"> </span><span class="no">NAME</span><span class="w"> </span><span class="g g-Other">...</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--rename</span><span class="w"> </span><span class="no">[ </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="w"> </span><span class="no">COMMAND</span><span class="g g-Other">]...</span><span class="no"> ]</span><span class="w"> </span><span class="no">OLD_WORD</span><span class="w"> </span><span class="no">NEW_WORD</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--show</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--list</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--query</span><span class="w"> </span><span class="no">NAME</span><span class="w"> </span><span class="g g-Other">...</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">abbr</span></code> manages abbreviations - user-defined words that are replaced with longer phrases when entered.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Only typed-in commands use abbreviations. Abbreviations are not expanded in scripts.</p>
</div>
<p>For example, a frequently-run command like <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span></code> can be abbreviated to <code class="docutils literal notranslate"><span class="pre">gco</span></code>.
After entering <code class="docutils literal notranslate"><span class="pre">gco</span></code> and pressing <kbd class="kbd docutils literal notranslate">space</kbd> or <kbd class="kbd docutils literal notranslate">enter</kbd>, the full text <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span></code> will appear in the command line.
To avoid expanding something that looks like an abbreviation, the default <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd> binding inserts a space without expanding.</p>
<p>An abbreviation may match a literal word, or it may match a pattern given by a regular expression. When an abbreviation matches a word, that word is replaced by new text, called its <em>expansion</em>. This expansion may be a fixed new phrase, or it can be dynamically created via a fish function. This expansion occurs after pressing space or enter.</p>
<p>Combining these features, it is possible to create custom syntaxes, where a regular expression recognizes matching tokens, and the expansion function interprets them. See the <a class="reference internal" href="#examples">Examples</a> section.</p>
<div class="versionchanged">
<p><span class="versionmodified changed">Changed in version 3.6.0: </span>Previous versions of this allowed saving abbreviations in universal variables.
That’s no longer possible. Existing variables will still be imported and <code class="docutils literal notranslate"><span class="pre">abbr</span> <span class="pre">--erase</span></code> will also erase the variables.
We recommend adding abbreviations to <a class="reference internal" href="../language.html#configuration"><span class="std std-ref">config.fish</span></a> by just adding the <code class="docutils literal notranslate"><span class="pre">abbr</span> <span class="pre">--add</span></code> command.
When you run <code class="docutils literal notranslate"><span class="pre">abbr</span></code>, you will see output like this</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt; </span><span class="nf">abbr</span>
<span class="go">abbr -a -- foo bar # imported from a universal variable, see `help abbr`</span>
</pre></div>
</div>
<p>In that case you should take the part before the <code class="docutils literal notranslate"><span class="pre">#</span></code> comment and save it in <a class="reference internal" href="../language.html#configuration"><span class="std std-ref">config.fish</span></a>,
then you can run <code class="docutils literal notranslate"><span class="pre">abbr</span> <span class="pre">--erase</span></code> to remove the universal variable:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt; </span><span class="nf">abbr</span><span class="w"> </span><span class="p">&gt;&gt;</span><span class="w"> </span><span class="p">~/.config/fish/config.fish</span>
<span class="gp">&gt; </span><span class="nf">abbr</span><span class="w"> </span><span class="no">--erase</span><span class="w"> </span><span class="o">(</span><span class="nf">abbr</span><span class="w"> </span><span class="no">--list</span><span class="o">)</span>
</pre></div>
</div>
<p>Alternatively you can keep them in a separate <a class="reference internal" href="../language.html#configuration"><span class="std std-ref">configuration file</span></a> by doing something like the following:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt; </span><span class="nf">abbr</span><span class="w"> </span><span class="p">&gt;</span><span class="w"> </span><span class="p">~/.config/fish/conf.d/myabbrs.fish</span>
</pre></div>
</div>
<p>This will save all your abbreviations in “myabbrs.fish”, overwriting the whole file so it doesn’t leave any duplicates,
or restore abbreviations you had erased.
Of course any functions will have to be saved separately, see <a class="reference internal" href="funcsave.html"><span class="doc">funcsave</span></a>.</p>
</div>
</section>
<section id="add-subcommand">
<h2>“add” subcommand<a class="headerlink" href="#add-subcommand" title="Link to this heading">¶</a></h2>
<div class="highlight-fish-synopsis notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">-a</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--add</span><span class="g g-Other">]</span><span class="w"> </span><span class="no">NAME</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">--position</span><span class="w"> </span><span class="no">command</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">anywhere</span><span class="g g-Other">]</span><span class="w"> </span><span class="g g-Other">[</span><span class="no">-r</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--regex</span><span class="w"> </span><span class="no">PATTERN</span><span class="g g-Other">]</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="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="no">--set-cursor</span><span class="g g-Other">[</span><span class="no">=MARKER</span><span class="g g-Other">]]</span><span class="w"> </span><span class="g g-Other">([</span><span class="no">-f</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">--function</span><span class="w"> </span><span class="no">FUNCTION</span><span class="g g-Other">]</span><span class="w"> </span><span class="g g-Other">|</span><span class="w"> </span><span class="no">EXPANSION</span><span class="g g-Other">)</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">abbr</span> <span class="pre">--add</span></code> creates a new abbreviation. With no other options, the string <strong>NAME</strong> is replaced by <strong>EXPANSION</strong>.</p>
<p>With <strong>--position command</strong>, the abbreviation will only expand when it is positioned as a command, not as an argument to another command. With <strong>--position anywhere</strong> the abbreviation may expand anywhere in the command line. The default is <strong>command</strong>.</p>
<p>With <strong>--command COMMAND</strong>, the abbreviation will only expand when it is used as an argument to the given COMMAND. Multiple <strong>--command</strong> can be used together, and the abbreviation will expand for each. An empty <strong>COMMAND</strong> means it will expand only when there is no command. <strong>--command</strong> implies <strong>--position anywhere</strong> and disallows <strong>--position command</strong>. Even with different <strong>COMMANDS</strong>, the <strong>NAME</strong> of the abbreviation needs to be unique. Consider using <strong>--regex</strong> if you want to expand the same word differently for multiple commands.</p>
<p>With <strong>--regex</strong>, the abbreviation matches using the regular expression given by <strong>PATTERN</strong>, instead of the literal <strong>NAME</strong>. The pattern is interpreted using PCRE2 syntax and must match the entire token. If multiple abbreviations match the same token, the last abbreviation added is used.</p>
<p>With <strong>--set-cursor=MARKER</strong>, the cursor is moved to the first occurrence of <strong>MARKER</strong> in the expansion. The <strong>MARKER</strong> value is erased. The <strong>MARKER</strong> may be omitted (i.e. simply <code class="docutils literal notranslate"><span class="pre">--set-cursor</span></code>), in which case it defaults to <code class="docutils literal notranslate"><span class="pre">%</span></code>.</p>
<p>With <strong>-f FUNCTION</strong> or <strong>--function FUNCTION</strong>, <strong>FUNCTION</strong> is treated as the name of a fish function instead of a literal replacement. When the abbreviation matches, the function will be called with the matching token as an argument. If the function’s exit status is 0 (success), the token will be replaced by the function’s output; otherwise the token will be left unchanged. No <strong>EXPANSION</strong> may be given separately.</p>
<section id="examples">
<h3>Examples<a class="headerlink" href="#examples" title="Link to this heading">¶</a></h3>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">--add</span><span class="w"> </span><span class="no">gco</span><span class="w"> </span><span class="no">git</span><span class="w"> </span><span class="no">checkout</span>
</pre></div>
</div>
<p>Add a new abbreviation where <code class="docutils literal notranslate"><span class="pre">gco</span></code> will be replaced with <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span></code>.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="no">--position</span><span class="w"> </span><span class="no">anywhere</span><span class="w"> </span><span class="no">--</span><span class="w"> </span><span class="no">-C</span><span class="w"> </span><span class="no">--color</span>
</pre></div>
</div>
<p>Add a new abbreviation where <code class="docutils literal notranslate"><span class="pre">-C</span></code> will be replaced with <code class="docutils literal notranslate"><span class="pre">--color</span></code>. The <code class="docutils literal notranslate"><span class="pre">--</span></code> allows <code class="docutils literal notranslate"><span class="pre">-C</span></code> to be treated as the name of the abbreviation, instead of an option.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="no">L</span><span class="w"> </span><span class="no">--position</span><span class="w"> </span><span class="no">anywhere</span><span class="w"> </span><span class="no">--set-cursor</span><span class="w"> </span><span class="s2">&quot;% | less&quot;</span>
</pre></div>
</div>
<p>Add a new abbreviation where <code class="docutils literal notranslate"><span class="pre">L</span></code> will be replaced with <code class="docutils literal notranslate"><span class="pre">|</span> <span class="pre">less</span></code>, placing the cursor before the pipe.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">function</span><span class="w"> </span><span class="no">last_history_item</span>
<span class="w">    </span><span class="nf">echo</span><span class="w"> </span><span class="o">$history[</span><span class="no">1</span><span class="o">]</span>
<span class="nf">end</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="no">!!</span><span class="w"> </span><span class="no">--position</span><span class="w"> </span><span class="no">anywhere</span><span class="w"> </span><span class="no">--function</span><span class="w"> </span><span class="no">last_history_item</span>
</pre></div>
</div>
<p>This first creates a function <code class="docutils literal notranslate"><span class="pre">last_history_item</span></code> which outputs the last entered command. It then adds an abbreviation which replaces <code class="docutils literal notranslate"><span class="pre">!!</span></code> with the result of calling this function. Taken together, this is similar to the <code class="docutils literal notranslate"><span class="pre">!!</span></code> history expansion feature of bash.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">function</span><span class="w"> </span><span class="no">vim_edit</span>
<span class="w">    </span><span class="nf">echo</span><span class="w"> </span><span class="no">vim</span><span class="w"> </span><span class="o">$argv</span>
<span class="nf">end</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">-a</span><span class="w"> </span><span class="no">vim_edit_texts</span><span class="w"> </span><span class="no">--position</span><span class="w"> </span><span class="no">command</span><span class="w"> </span><span class="no">--regex</span><span class="w"> </span><span class="s2">&quot;.+\.txt&quot;</span><span class="w"> </span><span class="no">--function</span><span class="w"> </span><span class="no">vim_edit</span>
</pre></div>
</div>
<p>This first creates a function <code class="docutils literal notranslate"><span class="pre">vim_edit</span></code> which prepends <code class="docutils literal notranslate"><span class="pre">vim</span></code> before its argument. It then adds an abbreviation which matches commands ending in <code class="docutils literal notranslate"><span class="pre">.txt</span></code>, and replaces the command with the result of calling this function. This allows text files to be “executed” as a command to open them in vim, similar to the “suffix alias” feature in zsh.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">4DIRS</span><span class="w"> </span><span class="no">--set-cursor=!</span><span class="w"> </span><span class="s2">&quot;</span><span class="o">$(</span><span class="nf">string</span><span class="w"> </span><span class="no">join</span><span class="w"> </span><span class="se">\n</span><span class="w"> </span><span class="no">--</span><span class="w"> </span><span class="s1">&#39;for dir in */&#39;</span><span class="w"> </span><span class="s1">&#39;cd $dir&#39;</span><span class="w"> </span><span class="s1">&#39;!&#39;</span><span class="w"> </span><span class="s1">&#39;cd ..&#39;</span><span class="w"> </span><span class="s1">&#39;end&#39;</span><span class="o">)</span><span class="s2">&quot;</span>
</pre></div>
</div>
<p>This creates an abbreviation “4DIRS” which expands to a multi-line loop “template.” The template enters each directory and then leaves it. The cursor is positioned ready to enter the command to run in each directory, at the location of the <code class="docutils literal notranslate"><span class="pre">!</span></code>, which is itself erased.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">--command</span><span class="w"> </span><span class="no">git</span><span class="w"> </span><span class="no">co</span><span class="w"> </span><span class="no">checkout</span>
</pre></div>
</div>
<p>Turns “co” as an argument to “git” into “checkout”. Multiple commands are possible, <code class="docutils literal notranslate"><span class="pre">--command={git,hg}</span></code> would expand “co” to “checkout” for both git and hg.</p>
</section>
</section>
<section id="other-subcommands">
<h2>Other subcommands<a class="headerlink" href="#other-subcommands" title="Link to this heading">¶</a></h2>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">--rename</span><span class="w"> </span><span class="no">[</span><span class="w"> </span><span class="no">[-c</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">--command</span><span class="w"> </span><span class="no">COMMAND]...</span><span class="w"> </span><span class="no">]</span><span class="w"> </span><span class="no">OLD_NAME</span><span class="w"> </span><span class="no">NEW_NAME</span>
</pre></div>
</div>
<p>Renames an abbreviation, from <em>OLD_NAME</em> to <em>NEW_NAME</em>.
For command-specific abbreviations, the <code class="docutils literal notranslate"><span class="pre">--command</span></code> options must be provided to disambiguate which abbreviation to rename.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">[-s</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">--show]</span>
</pre></div>
</div>
<p>Show all abbreviations in a manner suitable for import and export</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">[-l</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">--list]</span>
</pre></div>
</div>
<p>Prints the names of all abbreviation</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">[-e</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">--erase]</span><span class="w"> </span><span class="no">[</span><span class="w"> </span><span class="no">[-c</span><span class="w"> </span><span class="p">|</span><span class="w"> </span><span class="nf">--command</span><span class="w"> </span><span class="no">COMMAND]...</span><span class="w"> </span><span class="no">]</span><span class="w"> </span><span class="no">NAME</span><span class="w"> </span><span class="no">...</span>
</pre></div>
</div>
<p>Erases the abbreviation with the given name.
For command-specific abbreviations, the <code class="docutils literal notranslate"><span class="pre">--command</span></code> options must be provided to disambiguate which abbreviation to rename.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">-q</span><span class="w"> </span><span class="no">or</span><span class="w"> </span><span class="no">--query</span><span class="w"> </span><span class="no">[NAME...]</span>
</pre></div>
</div>
<p>Return 0 (true) if one of the <em>NAME</em> is an abbreviation.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">abbr</span><span class="w"> </span><span class="no">-h</span><span class="w"> </span><span class="no">or</span><span class="w"> </span><span class="no">--help</span>
</pre></div>
</div>
<p>Displays help for the <cite>abbr</cite> command.</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> &#187;</li>
    
    <a href="../index.html">fish-shell 4.2.1 documentation</a> &#187;
    

          <li class="nav-item nav-item-1"><a href="../commands.html" >Commands</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">abbr - manage fish abbreviations</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">
    &copy; 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>