File: interactive.html

package info (click to toggle)
fish 4.2.1-3.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,980 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (1043 lines) | stat: -rw-r--r-- 113,188 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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
<!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>Interactive use &#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="The fish language" href="language.html" />
    <link rel="prev" title="Frequently asked questions" href="faq.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-this"><a href="">Interactive use</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 current"><a class="current reference internal" href="#">Interactive use</a></li>
<li class="toctree-l1"><a class="reference internal" href="language.html">The fish language</a></li>
<li class="toctree-l1"><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="#">Interactive use</a><ul>
<li><a class="reference internal" href="#help">Help</a></li>
<li><a class="reference internal" href="#autosuggestions">Autosuggestions</a></li>
<li><a class="reference internal" href="#tab-completion">Tab Completion</a></li>
<li><a class="reference internal" href="#syntax-highlighting">Syntax highlighting</a><ul>
<li><a class="reference internal" href="#syntax-highlighting-variables">Syntax highlighting variables</a></li>
<li><a class="reference internal" href="#pager-color-variables">Pager color variables</a></li>
</ul>
</li>
<li><a class="reference internal" href="#abbreviations">Abbreviations</a></li>
<li><a class="reference internal" href="#programmable-prompt">Programmable prompt</a></li>
<li><a class="reference internal" href="#configurable-greeting">Configurable greeting</a></li>
<li><a class="reference internal" href="#programmable-title">Programmable title</a></li>
<li><a class="reference internal" href="#command-line-editor">Command line editor</a><ul>
<li><a class="reference internal" href="#shared-bindings">Shared bindings</a></li>
<li><a class="reference internal" href="#emacs-mode-commands">Emacs mode commands</a></li>
<li><a class="reference internal" href="#vi-mode-commands">Vi mode commands</a><ul>
<li><a class="reference internal" href="#command-mode">Command mode</a></li>
<li><a class="reference internal" href="#insert-mode">Insert mode</a></li>
<li><a class="reference internal" href="#visual-mode">Visual mode</a></li>
</ul>
</li>
<li><a class="reference internal" href="#custom-bindings">Custom bindings</a><ul>
<li><a class="reference internal" href="#key-sequences">Key sequences</a></li>
</ul>
</li>
<li><a class="reference internal" href="#copy-and-paste-kill-ring">Copy and paste (Kill Ring)</a></li>
<li><a class="reference internal" href="#multiline-editing">Multiline editing</a></li>
<li><a class="reference internal" href="#searchable-command-history">Searchable command history</a></li>
</ul>
</li>
<li><a class="reference internal" href="#private-mode">Private mode</a></li>
<li><a class="reference internal" href="#navigating-directories">Navigating directories</a><ul>
<li><a class="reference internal" href="#id16">Directory history</a></li>
<li><a class="reference internal" href="#directory-stack">Directory stack</a></li>
</ul>
</li>
</ul>
</li>
</ul>

</div>
        </div>
      </div>
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="interactive-use">
<h1>Interactive use<a class="headerlink" href="#interactive-use" title="Link to this heading">¶</a></h1>
<p>Fish prides itself on being really nice to use interactively. That’s down to a few features we’ll explain in the next few sections.</p>
<p>Fish is used by giving commands in the fish language, see <a class="reference internal" href="language.html"><span class="doc">The Fish Language</span></a> for information on that.</p>
<section id="help">
<h2>Help<a class="headerlink" href="#help" title="Link to this heading">¶</a></h2>
<p>Fish has an extensive help system. Use the <a class="reference internal" href="cmds/help.html"><span class="doc">help</span></a> command to obtain help on a specific subject or command. For instance, writing <code class="docutils literal notranslate"><span class="pre">help</span> <span class="pre">syntax</span></code> displays the <a class="reference internal" href="language.html#syntax"><span class="std std-ref">syntax section</span></a> of this documentation.</p>
<p>Fish also has man pages for its commands, and translates the help pages to man pages. For example, <code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">set</span></code> will show the documentation for <code class="docutils literal notranslate"><span class="pre">set</span></code> as a man page.</p>
<p>Help on a specific builtin can also be obtained with the <code class="docutils literal notranslate"><span class="pre">-h</span></code> parameter. For instance, to obtain help on the <a class="reference internal" href="cmds/fg.html"><span class="doc">fg</span></a> builtin, either type <code class="docutils literal notranslate"><span class="pre">fg</span> <span class="pre">-h</span></code> or <code class="docutils literal notranslate"><span class="pre">help</span> <span class="pre">fg</span></code>.</p>
<p>The main page can be viewed via <code class="docutils literal notranslate"><span class="pre">help</span> <span class="pre">index</span></code> (or just <code class="docutils literal notranslate"><span class="pre">help</span></code>) or <code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">fish-doc</span></code>. The tutorial can be viewed with <code class="docutils literal notranslate"><span class="pre">help</span> <span class="pre">tutorial</span></code> or <code class="docutils literal notranslate"><span class="pre">man</span> <span class="pre">fish-tutorial</span></code>.</p>
</section>
<section id="autosuggestions">
<span id="id1"></span><h2>Autosuggestions<a class="headerlink" href="#autosuggestions" title="Link to this heading">¶</a></h2>
<p>fish suggests commands as you type, based on <a class="reference internal" href="#history-search"><span class="std std-ref">command history</span></a>, completions, and valid file paths. As you type commands, you will see a suggestion offered after the cursor, in a muted gray color (which can be changed with the <code class="docutils literal notranslate"><span class="pre">fish_color_autosuggestion</span></code> variable).</p>
<p>To accept the autosuggestion (replacing the command line contents), press <kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd>. To accept the first suggested word, press <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) or <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd>. If the autosuggestion is not what you want, ignore it: it won’t execute unless you accept it.</p>
<p>Autosuggestions are a powerful way to quickly summon frequently entered commands, by typing the first few characters. They are also an efficient technique for navigating through directory hierarchies.</p>
<p>If you don’t like autosuggestions, you can disable them by setting <code class="docutils literal notranslate"><span class="pre">$fish_autosuggestion_enabled</span></code> to 0:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">-g</span><span class="w"> </span><span class="no">fish_autosuggestion_enabled</span><span class="w"> </span><span class="no">0</span>
</pre></div>
</div>
</section>
<section id="tab-completion">
<span id="id2"></span><h2>Tab Completion<a class="headerlink" href="#tab-completion" title="Link to this heading">¶</a></h2>
<p>Tab completion is a time saving feature of any modern shell. When you type <kbd class="kbd docutils literal notranslate">tab</kbd>, fish tries to guess the rest of the word under the cursor. If it finds exactly one possibility, it inserts it. If it finds more, it inserts the longest unambiguous part and then opens a menu (the “pager”) that you can navigate to find what you’re looking for.</p>
<p>The pager can be navigated with the arrow keys, <kbd class="kbd docutils literal notranslate">pageup</kbd> / <kbd class="kbd docutils literal notranslate">pagedown</kbd>, <kbd class="kbd docutils literal notranslate">tab</kbd> or <kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">tab</kbd>. Pressing <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">s</kbd> (the <code class="docutils literal notranslate"><span class="pre">pager-toggle-search</span></code> binding - <kbd class="kbd docutils literal notranslate">/</kbd> in vi mode) opens up a search menu that you can use to filter the list.</p>
<p>Fish provides some general purpose completions, like for commands, variable names, usernames or files.</p>
<p>It also provides a large number of program specific scripted completions. Most of these completions are simple options like the <code class="docutils literal notranslate"><span class="pre">-l</span></code> option for <code class="docutils literal notranslate"><span class="pre">ls</span></code>, but a lot are more advanced. For example:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">man</span></code> and <code class="docutils literal notranslate"><span class="pre">whatis</span></code> show the installed manual pages as completions.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">make</span></code> uses targets in the Makefile in the current directory as completions.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">mount</span></code> uses mount points specified in fstab as completions.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">apt</span></code>, <code class="docutils literal notranslate"><span class="pre">rpm</span></code> and <code class="docutils literal notranslate"><span class="pre">yum</span></code> show installed or installable packages</p></li>
</ul>
<p>You can also write your own completions or install some you got from someone else. For that, see <a class="reference internal" href="completions.html"><span class="doc">Writing your own completions</span></a>.</p>
<p>Completion scripts are loaded on demand, like <a class="reference internal" href="language.html#syntax-function-autoloading"><span class="std std-ref">functions are</span></a>. The difference is the <code class="docutils literal notranslate"><span class="pre">$fish_complete_path</span></code> <a class="reference internal" href="language.html#variables-lists"><span class="std std-ref">list</span></a> is used instead of <code class="docutils literal notranslate"><span class="pre">$fish_function_path</span></code>. Typically you can drop new completions in ~/.config/fish/completions/name-of-command.fish and fish will find them automatically.</p>
</section>
<section id="syntax-highlighting">
<span id="id3"></span><h2>Syntax highlighting<a class="headerlink" href="#syntax-highlighting" title="Link to this heading">¶</a></h2>
<p>Fish interprets the command line as it is typed and uses syntax highlighting to provide feedback. The most important feedback is the detection of potential errors. By default, errors are marked red.</p>
<p>Detected errors include:</p>
<ul class="simple">
<li><p>Non-existing commands.</p></li>
<li><p>Reading from or appending to a non-existing file.</p></li>
<li><p>Incorrect use of output redirects</p></li>
<li><p>Mismatched parenthesis</p></li>
</ul>
<p>To customize the syntax highlighting, you can set the environment variables listed in the <a class="reference internal" href="#variables-color"><span class="std std-ref">Variables for changing highlighting colors</span></a> section.</p>
<p>Fish also provides pre-made color themes you can pick with <a class="reference internal" href="cmds/fish_config.html"><span class="doc">fish_config</span></a>. Running just <code class="docutils literal notranslate"><span class="pre">fish_config</span></code> opens a browser interface, or you can use <code class="docutils literal notranslate"><span class="pre">fish_config</span> <span class="pre">theme</span></code> in the terminal.</p>
<p>For example, to disable nearly all coloring:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">fish_config</span><span class="w"> </span><span class="no">theme</span><span class="w"> </span><span class="no">choose</span><span class="w"> </span><span class="no">None</span>
</pre></div>
</div>
<p>Or, to see all themes, right in your terminal:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">fish_config</span><span class="w"> </span><span class="no">theme</span><span class="w"> </span><span class="no">show</span>
</pre></div>
</div>
<section id="syntax-highlighting-variables">
<span id="variables-color"></span><h3>Syntax highlighting variables<a class="headerlink" href="#syntax-highlighting-variables" title="Link to this heading">¶</a></h3>
<p>The colors used by fish for syntax highlighting can be configured by changing the values of various variables. The value of these variables can be one of the colors accepted by the <a class="reference internal" href="cmds/set_color.html"><span class="doc">set_color</span></a> command.
Options accepted by <code class="docutils literal notranslate"><span class="pre">set_color</span></code> like
<code class="docutils literal notranslate"><span class="pre">--background=</span></code>,
<code class="docutils literal notranslate"><span class="pre">--bold</span></code>,
<code class="docutils literal notranslate"><span class="pre">--dim</span></code>,
<code class="docutils literal notranslate"><span class="pre">--italics</span></code>,
<code class="docutils literal notranslate"><span class="pre">--reverse</span></code>,
<code class="docutils literal notranslate"><span class="pre">--underline</span></code> and
<code class="docutils literal notranslate"><span class="pre">--underline-color=</span></code>
are also accepted.</p>
<p>Example: to make errors highlighted and red, use:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">fish_color_error</span><span class="w"> </span><span class="no">red</span><span class="w"> </span><span class="no">--bold</span>
</pre></div>
</div>
<p>The following variables are available to change the highlighting colors in fish:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Variable</p></th>
<th class="head"><p>Meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_normal">
<span class="sig-name descname"><span class="pre">fish_color_normal</span></span><a class="headerlink" href="#envvar-fish_color_normal" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>default color</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_command">
<span class="sig-name descname"><span class="pre">fish_color_command</span></span><a class="headerlink" href="#envvar-fish_color_command" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>commands like echo</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_keyword">
<span class="sig-name descname"><span class="pre">fish_color_keyword</span></span><a class="headerlink" href="#envvar-fish_color_keyword" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>keywords like if - this falls back on the command color if unset</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_quote">
<span class="sig-name descname"><span class="pre">fish_color_quote</span></span><a class="headerlink" href="#envvar-fish_color_quote" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>quoted text like <code class="docutils literal notranslate"><span class="pre">&quot;abc&quot;</span></code></p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_redirection">
<span class="sig-name descname"><span class="pre">fish_color_redirection</span></span><a class="headerlink" href="#envvar-fish_color_redirection" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>IO redirections like &gt;/dev/null</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_end">
<span class="sig-name descname"><span class="pre">fish_color_end</span></span><a class="headerlink" href="#envvar-fish_color_end" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>process separators like <code class="docutils literal notranslate"><span class="pre">;</span></code> and <code class="docutils literal notranslate"><span class="pre">&amp;</span></code></p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_error">
<span class="sig-name descname"><span class="pre">fish_color_error</span></span><a class="headerlink" href="#envvar-fish_color_error" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>syntax errors</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_param">
<span class="sig-name descname"><span class="pre">fish_color_param</span></span><a class="headerlink" href="#envvar-fish_color_param" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>ordinary command parameters</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_valid_path">
<span class="sig-name descname"><span class="pre">fish_color_valid_path</span></span><a class="headerlink" href="#envvar-fish_color_valid_path" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>parameters that are filenames (if the file exists)</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_option">
<span class="sig-name descname"><span class="pre">fish_color_option</span></span><a class="headerlink" href="#envvar-fish_color_option" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>options starting with “-”, up to the first “--” parameter</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_comment">
<span class="sig-name descname"><span class="pre">fish_color_comment</span></span><a class="headerlink" href="#envvar-fish_color_comment" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>comments like ‘# important’</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_selection">
<span class="sig-name descname"><span class="pre">fish_color_selection</span></span><a class="headerlink" href="#envvar-fish_color_selection" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>selected text in vi visual mode</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_operator">
<span class="sig-name descname"><span class="pre">fish_color_operator</span></span><a class="headerlink" href="#envvar-fish_color_operator" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>parameter expansion operators like <code class="docutils literal notranslate"><span class="pre">*</span></code> and <code class="docutils literal notranslate"><span class="pre">~</span></code></p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_escape">
<span class="sig-name descname"><span class="pre">fish_color_escape</span></span><a class="headerlink" href="#envvar-fish_color_escape" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>character escapes like <code class="docutils literal notranslate"><span class="pre">\n</span></code> and <code class="docutils literal notranslate"><span class="pre">\x70</span></code></p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_autosuggestion">
<span class="sig-name descname"><span class="pre">fish_color_autosuggestion</span></span><a class="headerlink" href="#envvar-fish_color_autosuggestion" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>autosuggestions (the proposed rest of a command)</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_cwd">
<span class="sig-name descname"><span class="pre">fish_color_cwd</span></span><a class="headerlink" href="#envvar-fish_color_cwd" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the current working directory in the default prompt</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_cwd_root">
<span class="sig-name descname"><span class="pre">fish_color_cwd_root</span></span><a class="headerlink" href="#envvar-fish_color_cwd_root" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the current working directory in the default prompt for the root user</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_user">
<span class="sig-name descname"><span class="pre">fish_color_user</span></span><a class="headerlink" href="#envvar-fish_color_user" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the username in the default prompt</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_host">
<span class="sig-name descname"><span class="pre">fish_color_host</span></span><a class="headerlink" href="#envvar-fish_color_host" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the hostname in the default prompt</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_host_remote">
<span class="sig-name descname"><span class="pre">fish_color_host_remote</span></span><a class="headerlink" href="#envvar-fish_color_host_remote" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the hostname in the default prompt for remote sessions (like ssh)</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_status">
<span class="sig-name descname"><span class="pre">fish_color_status</span></span><a class="headerlink" href="#envvar-fish_color_status" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the last command’s nonzero exit code in the default prompt</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_cancel">
<span class="sig-name descname"><span class="pre">fish_color_cancel</span></span><a class="headerlink" href="#envvar-fish_color_cancel" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the ‘^C’ indicator on a canceled command</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_search_match">
<span class="sig-name descname"><span class="pre">fish_color_search_match</span></span><a class="headerlink" href="#envvar-fish_color_search_match" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>history search matches and selected pager items (background only)</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_color_history_current">
<span class="sig-name descname"><span class="pre">fish_color_history_current</span></span><a class="headerlink" href="#envvar-fish_color_history_current" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the current position in the history for commands like <code class="docutils literal notranslate"><span class="pre">dirh</span></code> and <code class="docutils literal notranslate"><span class="pre">cdh</span></code></p></td>
</tr>
</tbody>
</table>
<p>If a variable isn’t set or is empty, fish usually tries <code class="docutils literal notranslate"><span class="pre">$fish_color_normal</span></code>, except for:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">$fish_color_keyword</span></code>, where it tries <code class="docutils literal notranslate"><span class="pre">$fish_color_command</span></code> first.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">$fish_color_option</span></code>, where it tries <code class="docutils literal notranslate"><span class="pre">$fish_color_param</span></code> first.</p></li>
<li><p>For <code class="docutils literal notranslate"><span class="pre">$fish_color_valid_path</span></code>, if that doesn’t have a color, but only modifiers, it adds those to the color that would otherwise be used,
like <code class="docutils literal notranslate"><span class="pre">$fish_color_param</span></code>. But if valid paths have a color, it uses that and adds in modifiers from the other color.</p></li>
</ul>
</section>
<section id="pager-color-variables">
<h3>Pager color variables<a class="headerlink" href="#pager-color-variables" title="Link to this heading">¶</a></h3>
<p>fish will sometimes present a list of choices in a table, called the pager.</p>
<p>Example: to set the background of each pager row, use:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_background</span><span class="w"> </span><span class="no">--background=white</span>
</pre></div>
</div>
<p>To have black text on alternating white and gray backgrounds:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_prefix</span><span class="w"> </span><span class="no">black</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_completion</span><span class="w"> </span><span class="no">black</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_description</span><span class="w"> </span><span class="no">black</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_background</span><span class="w"> </span><span class="no">--background=white</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_pager_color_secondary_background</span><span class="w"> </span><span class="no">--background=brwhite</span>
</pre></div>
</div>
<p>Variables affecting the pager colors:</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Variable</p></th>
<th class="head"><p>Meaning</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_progress">
<span class="sig-name descname"><span class="pre">fish_pager_color_progress</span></span><a class="headerlink" href="#envvar-fish_pager_color_progress" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the progress bar at the bottom left corner</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_background">
<span class="sig-name descname"><span class="pre">fish_pager_color_background</span></span><a class="headerlink" href="#envvar-fish_pager_color_background" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the background color of a line</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_prefix">
<span class="sig-name descname"><span class="pre">fish_pager_color_prefix</span></span><a class="headerlink" href="#envvar-fish_pager_color_prefix" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the prefix string, i.e. the string that is to be completed</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_completion">
<span class="sig-name descname"><span class="pre">fish_pager_color_completion</span></span><a class="headerlink" href="#envvar-fish_pager_color_completion" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the completion itself, i.e. the proposed rest of the string</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_description">
<span class="sig-name descname"><span class="pre">fish_pager_color_description</span></span><a class="headerlink" href="#envvar-fish_pager_color_description" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>the completion description</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_selected_background">
<span class="sig-name descname"><span class="pre">fish_pager_color_selected_background</span></span><a class="headerlink" href="#envvar-fish_pager_color_selected_background" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>background of the selected completion</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_selected_prefix">
<span class="sig-name descname"><span class="pre">fish_pager_color_selected_prefix</span></span><a class="headerlink" href="#envvar-fish_pager_color_selected_prefix" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>prefix of the selected completion</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_selected_completion">
<span class="sig-name descname"><span class="pre">fish_pager_color_selected_completion</span></span><a class="headerlink" href="#envvar-fish_pager_color_selected_completion" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>suffix of the selected completion</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_selected_description">
<span class="sig-name descname"><span class="pre">fish_pager_color_selected_description</span></span><a class="headerlink" href="#envvar-fish_pager_color_selected_description" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>description of the selected completion</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_secondary_background">
<span class="sig-name descname"><span class="pre">fish_pager_color_secondary_background</span></span><a class="headerlink" href="#envvar-fish_pager_color_secondary_background" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>background of every second unselected completion</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_secondary_prefix">
<span class="sig-name descname"><span class="pre">fish_pager_color_secondary_prefix</span></span><a class="headerlink" href="#envvar-fish_pager_color_secondary_prefix" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>prefix of every second unselected completion</p></td>
</tr>
<tr class="row-odd"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_secondary_completion">
<span class="sig-name descname"><span class="pre">fish_pager_color_secondary_completion</span></span><a class="headerlink" href="#envvar-fish_pager_color_secondary_completion" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>suffix of every second unselected completion</p></td>
</tr>
<tr class="row-even"><td><dl class="std envvar">
<dt class="sig sig-object std" id="envvar-fish_pager_color_secondary_description">
<span class="sig-name descname"><span class="pre">fish_pager_color_secondary_description</span></span><a class="headerlink" href="#envvar-fish_pager_color_secondary_description" title="Link to this definition">¶</a></dt>
<dd></dd></dl>

</td>
<td><p>description of every second unselected completion</p></td>
</tr>
</tbody>
</table>
<p>When the secondary or selected variables aren’t set or are empty, the normal variables are used, except for <code class="docutils literal notranslate"><span class="pre">$fish_pager_color_selected_background</span></code>, where the background of <code class="docutils literal notranslate"><span class="pre">$fish_color_search_match</span></code> is tried first.</p>
</section>
</section>
<section id="abbreviations">
<span id="id4"></span><h2>Abbreviations<a class="headerlink" href="#abbreviations" title="Link to this heading">¶</a></h2>
<p>To avoid needless typing, 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> using the <a class="reference internal" href="cmds/abbr.html"><span class="doc">abbr</span></a> command.</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">gco</span><span class="w"> </span><span class="no">git</span><span class="w"> </span><span class="no">checkout</span>
</pre></div>
</div>
<p>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>, a <code class="docutils literal notranslate"><span class="pre">gco</span></code> in command position will turn into <code class="docutils literal notranslate"><span class="pre">git</span> <span class="pre">checkout</span></code> in the command line. If you want to use a literal <code class="docutils literal notranslate"><span class="pre">gco</span></code> sometimes, use <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd> <a class="footnote-reference brackets" href="#id6" id="id5" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>.</p>
<p>Abbreviations are a lot more powerful than just replacing literal strings. For example you can make going up a number of directories easier with this:</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">multicd</span>
<span class="w">    </span><span class="nf">echo</span><span class="w"> </span><span class="no">cd</span><span class="w"> </span><span class="o">(</span><span class="nf">string</span><span class="w"> </span><span class="no">repeat</span><span class="w"> </span><span class="no">-n</span><span class="w"> </span><span class="o">(</span><span class="nf">math</span><span class="w"> </span><span class="o">(</span><span class="nf">string</span><span class="w"> </span><span class="no">length</span><span class="w"> </span><span class="no">--</span><span class="w"> </span><span class="o">$argv[</span><span class="no">1</span><span class="o">])</span><span class="w"> </span><span class="no">-</span><span class="w"> </span><span class="no">1</span><span class="o">)</span><span class="w"> </span><span class="no">../</span><span class="o">)</span>
<span class="nf">end</span>
<span class="nf">abbr</span><span class="w"> </span><span class="no">--add</span><span class="w"> </span><span class="no">dotdot</span><span class="w"> </span><span class="no">--regex</span><span class="w"> </span><span class="s1">&#39;^\.\.+$&#39;</span><span class="w"> </span><span class="no">--function</span><span class="w"> </span><span class="no">multicd</span>
</pre></div>
</div>
<p>Now, <code class="docutils literal notranslate"><span class="pre">..</span></code> transforms to <code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">../</span></code>, while <code class="docutils literal notranslate"><span class="pre">...</span></code> turns into <code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">../../</span></code> and <code class="docutils literal notranslate"><span class="pre">....</span></code> expands to <code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">../../../</span></code>.</p>
<p>The advantage over aliases is that you can see the actual command before using it, add to it or change it, and the actual command will be stored in history.</p>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id6" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id5">1</a><span class="fn-bracket">]</span></span>
<p>Any binding that executes the <code class="docutils literal notranslate"><span class="pre">expand-abbr</span></code> or <code class="docutils literal notranslate"><span class="pre">execute</span></code> <a class="reference internal" href="cmds/bind.html"><span class="doc">bind function</span></a> will expand abbreviations. By default <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd> is bound to just inserting a space.</p>
</aside>
</aside>
</section>
<section id="programmable-prompt">
<span id="prompt"></span><h2>Programmable prompt<a class="headerlink" href="#programmable-prompt" title="Link to this heading">¶</a></h2>
<p>When it is fish’s turn to ask for input (like after it started or the command ended), it will show a prompt. Often this looks something like:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">you@hostname</span><span class="w"> </span><span class="o">~</span><span class="p">&gt;</span>
</pre></div>
</div>
<p>This prompt is determined by running the <a class="reference internal" href="cmds/fish_prompt.html"><span class="doc">fish_prompt</span></a> and <a class="reference internal" href="cmds/fish_right_prompt.html"><span class="doc">fish_right_prompt</span></a> functions.</p>
<p>The output of the former is displayed on the left and the latter’s output on the right side of the terminal.
For <a class="reference internal" href="#vi-mode"><span class="std std-ref">vi mode</span></a>, the output of <a class="reference internal" href="cmds/fish_mode_prompt.html"><span class="doc">fish_mode_prompt</span></a> will be prepended on the left.</p>
<p>If <span class="target" id="index-0"></span><a class="reference internal" href="language.html#envvar-fish_transient_prompt"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">fish_transient_prompt</span></code></a> is set to 1, fish will redraw the prompt with a <code class="docutils literal notranslate"><span class="pre">--final-rendering</span></code> argument before running a commandline, allowing you to change it before pushing it to the scrollback.</p>
<p>Fish ships with a few prompts which you can see with <a class="reference internal" href="cmds/fish_config.html"><span class="doc">fish_config</span></a>. If you run just <code class="docutils literal notranslate"><span class="pre">fish_config</span></code> it will open a web interface <a class="footnote-reference brackets" href="#id8" id="id7" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> where you’ll be shown the prompts and can pick which one you want. <code class="docutils literal notranslate"><span class="pre">fish_config</span> <span class="pre">prompt</span> <span class="pre">show</span></code> will show you the prompts right in your terminal.</p>
<p>For example <code class="docutils literal notranslate"><span class="pre">fish_config</span> <span class="pre">prompt</span> <span class="pre">choose</span> <span class="pre">disco</span></code> will temporarily select the “disco” prompt. If you like it and decide to keep it, run <code class="docutils literal notranslate"><span class="pre">fish_config</span> <span class="pre">prompt</span> <span class="pre">save</span></code>.</p>
<p>You can also change these functions yourself by running <code class="docutils literal notranslate"><span class="pre">funced</span> <span class="pre">fish_prompt</span></code> and <code class="docutils literal notranslate"><span class="pre">funcsave</span> <span class="pre">fish_prompt</span></code> once you are happy with the result (or <code class="docutils literal notranslate"><span class="pre">fish_right_prompt</span></code> if you want to change that).</p>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id8" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id7">2</a><span class="fn-bracket">]</span></span>
<p>The web interface runs purely locally on your computer and requires python to be installed.</p>
</aside>
</aside>
</section>
<section id="configurable-greeting">
<h2>Configurable greeting<a class="headerlink" href="#configurable-greeting" title="Link to this heading">¶</a></h2>
<p>When it is started interactively, fish tries to run the <a class="reference internal" href="cmds/fish_greeting.html"><span class="doc">fish_greeting</span></a> function. The default fish_greeting prints a simple message. You can change its text by changing the <code class="docutils literal notranslate"><span class="pre">$fish_greeting</span></code> variable, for instance using a <a class="reference internal" href="language.html#variables-universal"><span class="std std-ref">universal variable</span></a>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">-U</span><span class="w"> </span><span class="no">fish_greeting</span>
</pre></div>
</div>
<p>or you can set it <a class="reference internal" href="language.html#variables-scope"><span class="std std-ref">globally</span></a> in <a class="reference internal" href="language.html#configuration"><span class="std std-ref">config.fish</span></a>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">-g</span><span class="w"> </span><span class="no">fish_greeting</span><span class="w"> </span><span class="s1">&#39;Hey, stranger!&#39;</span>
</pre></div>
</div>
<p>or you can script it by changing the function:</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">fish_greeting</span>
<span class="w">    </span><span class="nf">random</span><span class="w"> </span><span class="no">choice</span><span class="w"> </span><span class="s2">&quot;Hello!&quot;</span><span class="w"> </span><span class="s2">&quot;Hi&quot;</span><span class="w"> </span><span class="s2">&quot;G&#39;day&quot;</span><span class="w"> </span><span class="s2">&quot;Howdy&quot;</span>
<span class="nf">end</span>
</pre></div>
</div>
<p>save this in config.fish or <a class="reference internal" href="language.html#syntax-function-autoloading"><span class="std std-ref">a function file</span></a>. You can also use <a class="reference internal" href="cmds/funced.html"><span class="doc">funced</span></a> and <a class="reference internal" href="cmds/funcsave.html"><span class="doc">funcsave</span></a> to edit it easily.</p>
</section>
<section id="programmable-title">
<h2>Programmable title<a class="headerlink" href="#programmable-title" title="Link to this heading">¶</a></h2>
<p>Most terminals allow setting the text displayed in the titlebar of the terminal window.
Fish does this by running the <a class="reference internal" href="cmds/fish_title.html"><span class="doc">fish_title</span></a> function.
It is executed before and after a command and the output is used as a titlebar message.</p>
<p>The <a class="reference internal" href="cmds/status.html"><span class="doc">status current-command</span></a> builtin will always return the name of the job to be put into the foreground (or <code class="docutils literal notranslate"><span class="pre">fish</span></code> if control is returning to the shell) when the <a class="reference internal" href="cmds/fish_title.html"><span class="doc">fish_title</span></a> function is called. The first argument will contain the most recently executed foreground command as a string.</p>
<p>The default title shows the hostname if connected via ssh, the currently running command (unless it is fish) and the current working directory. All of this is shortened to not make the tab too wide.</p>
<p>Examples:</p>
<p>To show the last command and working directory in the title:</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">fish_title</span>
<span class="w">    </span><span class="c"># `prompt_pwd` shortens the title. This helps prevent tabs from becoming very wide.</span>
<span class="w">    </span><span class="nf">echo</span><span class="w"> </span><span class="o">$argv[</span><span class="no">1</span><span class="o">]</span><span class="w"> </span><span class="o">(</span><span class="nf">prompt_pwd</span><span class="o">)</span>
<span class="w">    </span><span class="nf">pwd</span>
<span class="nf">end</span>
</pre></div>
</div>
</section>
<section id="command-line-editor">
<span id="editor"></span><h2>Command line editor<a class="headerlink" href="#command-line-editor" title="Link to this heading">¶</a></h2>
<p>The fish editor features copy and paste, a <a class="reference internal" href="#history-search"><span class="std std-ref">searchable history</span></a> and many editor functions that can be bound to special keyboard shortcuts.</p>
<p>Like bash and other shells, fish includes two sets of keyboard shortcuts (or key bindings): one inspired by the Emacs text editor, and one by the vi text editor. The default editing mode is Emacs. You can switch to vi mode by running <a class="reference internal" href="cmds/fish_vi_key_bindings.html"><span class="doc">fish_vi_key_bindings</span></a> and switch back with <a class="reference internal" href="cmds/fish_default_key_bindings.html"><span class="doc">fish_default_key_bindings</span></a>. You can also make your own key bindings by creating a function and setting the <code class="docutils literal notranslate"><span class="pre">fish_key_bindings</span></code> variable to its name. For example:</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">fish_hybrid_key_bindings</span><span class="w"> </span><span class="no">--description</span><span class="nv"> \</span>
<span class="s2">&quot;Vi-style bindings that inherit emacs-style bindings in all modes&quot;</span>
<span class="w">    </span><span class="nf">for</span><span class="w"> </span><span class="no">mode</span><span class="w"> </span><span class="nf">in</span><span class="w"> </span><span class="no">default</span><span class="w"> </span><span class="no">insert</span><span class="w"> </span><span class="no">visual</span>
<span class="w">        </span><span class="nf">fish_default_key_bindings</span><span class="w"> </span><span class="no">-M</span><span class="w"> </span><span class="o">$mode</span>
<span class="w">    </span><span class="nf">end</span>
<span class="w">    </span><span class="nf">fish_vi_key_bindings</span><span class="w"> </span><span class="no">--no-erase</span>
<span class="nf">end</span>
<span class="nf">set</span><span class="w"> </span><span class="no">-g</span><span class="w"> </span><span class="no">fish_key_bindings</span><span class="w"> </span><span class="no">fish_hybrid_key_bindings</span>
</pre></div>
</div>
<p>While the key bindings included with fish include many of the shortcuts popular from the respective text editors, they are not a complete implementation. They include a shortcut to open the current command line in your preferred editor (<kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd> by default) if you need the full power of your editor.</p>
<section id="shared-bindings">
<span id="shared-binds"></span><h3>Shared bindings<a class="headerlink" href="#shared-bindings" title="Link to this heading">¶</a></h3>
<p>Some bindings are common across Emacs and vi mode, because they aren’t text editing bindings, or because what vi/Vim does for a particular key doesn’t make sense for a shell.</p>
<ul class="simple">
<li><p><kbd class="kbd docutils literal notranslate">tab</kbd> <a class="reference internal" href="#tab-completion"><span class="std std-ref">completes</span></a> the current token. <kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">tab</kbd> completes the current token and starts the pager’s search mode. <kbd class="kbd docutils literal notranslate">tab</kbd> is the same as <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">i</kbd>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>) and <kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) move the cursor left or right by one character. If the cursor is already at the end of the line, and an autosuggestion is available, <kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) accepts the autosuggestion.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">enter</kbd> executes the current commandline or inserts a newline if it’s not complete yet (e.g. a <code class="docutils literal notranslate"><span class="pre">)</span></code> or <code class="docutils literal notranslate"><span class="pre">end</span></code> is missing).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">enter</kbd> inserts a newline at the cursor position. This is useful to add a line to a commandline that’s already complete.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>) and <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) move the cursor left or right by one argument (or one word on macOS).
If the command line is empty, they move forward/backward in the directory history.
If the cursor is already at the end of the line, and an autosuggestion is available, <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) (or <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd>) accepts the first argument (or word on macOS) in the suggestion.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>) and <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) move the cursor left or right by one word. These accept one word of the autosuggestion - the part they’d move over.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>) and <kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) move the cursor one word left or right, without stopping on punctuation. These accept one big word of the autosuggestion.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">up</kbd> (<code class="docutils literal notranslate"><span class="pre">↑</span></code>) and <kbd class="kbd docutils literal notranslate">down</kbd> (<code class="docutils literal notranslate"><span class="pre">↓</span></code>) (or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd> and <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd> for emacs aficionados) search the command history for the previous/next command containing the string that was specified on the commandline before the search was started. If the commandline was empty when the search started, all commands match. See the <a class="reference internal" href="#history-search"><span class="std std-ref">history</span></a> section for more information on history searching.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">up</kbd> (<code class="docutils literal notranslate"><span class="pre">↑</span></code>) and <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">down</kbd> (<code class="docutils literal notranslate"><span class="pre">↓</span></code>) search the command history for the previous/next token containing the token under the cursor before the search was started. If the commandline was not on a token when the search started, all tokens match. See the <a class="reference internal" href="#history-search"><span class="std std-ref">history</span></a> section for more information on history searching.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd> interrupts/kills whatever is running (SIGINT).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd> deletes one character to the right of the cursor. If the command line is empty, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd> will exit fish.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">u</kbd> removes contents from the beginning of line to the cursor (moving it to the <a class="reference internal" href="#killring"><span class="std std-ref">killring</span></a>).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">l</kbd> pushes any text above the prompt to the terminal’s scrollback,
then clears and repaints the screen.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">w</kbd> removes the previous path component (everything up to the previous “/”, “:” or “&#64;”) (moving it to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">x</kbd> copies the current buffer to the system’s clipboard, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">v</kbd> inserts the clipboard contents. (see <a class="reference internal" href="cmds/fish_clipboard_copy.html"><span class="doc">fish_clipboard_copy</span></a> and <a class="reference internal" href="cmds/fish_clipboard_paste.html"><span class="doc">fish_clipboard_paste</span></a>)</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd> moves the next word to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">delete</kbd> moves the next word (or next argument on macOS) to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">d</kbd> lists the directory history if the command line is empty.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">delete</kbd> moves the next argument (or word on macOS) to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">delete</kbd> removes the current history item or autosuggestion from the command history.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">h</kbd> (or <kbd class="kbd docutils literal notranslate">f1</kbd>) shows the manual page for the current command, if one exists.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">l</kbd> lists the contents of the current directory, unless the cursor is over a directory argument, in which case the contents of that directory will be listed.</p></li>
</ul>
<ul class="simple" id="shared-binds-alt-o">
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">o</kbd> opens the file at the cursor in a pager. If the cursor is in command position and the command is a script, it will instead open that script in your editor. The editor is chosen from the first available of the <code class="docutils literal notranslate"><span class="pre">$VISUAL</span></code> or <code class="docutils literal notranslate"><span class="pre">$EDITOR</span></code> variables.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd> adds the string <code class="docutils literal notranslate"><span class="pre">&amp;|</span> <span class="pre">less;</span></code> to the end of the job under the cursor. The result is that the output of the command will be paged. If you set the <code class="docutils literal notranslate"><span class="pre">PAGER</span></code> variable, its value is used instead of <code class="docutils literal notranslate"><span class="pre">less</span></code>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">w</kbd> prints a short description of the command under the cursor.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd> edits the current command line in an external editor. The editor is chosen from the first available of the <code class="docutils literal notranslate"><span class="pre">$VISUAL</span></code> or <code class="docutils literal notranslate"><span class="pre">$EDITOR</span></code> variables.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">v</kbd> Same as <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">s</kbd> Prepends <code class="docutils literal notranslate"><span class="pre">sudo</span></code> to the current commandline. If the commandline is empty, prepend <code class="docutils literal notranslate"><span class="pre">sudo</span></code> to the last commandline. If <code class="docutils literal notranslate"><span class="pre">sudo</span></code> is not installed, various similar commands are tried: <code class="docutils literal notranslate"><span class="pre">doas</span></code>, <code class="docutils literal notranslate"><span class="pre">please</span></code>, and <code class="docutils literal notranslate"><span class="pre">run0</span></code>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">space</kbd> Inserts a space without expanding an <a class="reference internal" href="#abbreviations"><span class="std std-ref">abbreviation</span></a>. For vi mode, this only applies to insert-mode.</p></li>
</ul>
</section>
<section id="emacs-mode-commands">
<span id="emacs-mode"></span><h3>Emacs mode commands<a class="headerlink" href="#emacs-mode-commands" title="Link to this heading">¶</a></h3>
<p>To enable emacs mode, use <a class="reference internal" href="cmds/fish_default_key_bindings.html"><span class="doc">fish_default_key_bindings</span></a>. This is also the default.</p>
<ul class="simple">
<li><p><kbd class="kbd docutils literal notranslate">home</kbd> or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">a</kbd> moves the cursor to the beginning of the line.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">end</kbd> or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd> moves to the end of line. If the cursor is already at the end of the line, and an autosuggestion is available, <kbd class="kbd docutils literal notranslate">end</kbd> or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">e</kbd> accepts the autosuggestion.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">b</kbd>, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd> move the cursor one character left or right or accept the autosuggestion just like the <kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>) and <kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>) shared bindings (which are available as well).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">b</kbd>, <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">f</kbd> move the cursor one word left or right, or accept one word of the autosuggestion. If the command line is empty, moves forward/backward in the directory history instead.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd>, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">p</kbd> move the cursor up/down or through history, like the up and down arrow shared bindings.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">delete</kbd> or <kbd class="kbd docutils literal notranslate">backspace</kbd> or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">h</kbd> removes one character forwards or backwards respectively.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">backspace</kbd> removes one word backwards and <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">backspace</kbd> removes one argument backwards.
On macOS, it’s the other way round.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">&lt;</kbd> moves to the beginning of the commandline, <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">&gt;</kbd> moves to the end.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">k</kbd> deletes from the cursor to the end of line (moving it to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">escape</kbd> and <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">g</kbd> cancel the current operation. Immediately after an unambiguous completion this undoes it.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd> capitalizes the current word.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">u</kbd> makes the current word uppercase.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">t</kbd> transposes the last two characters.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">t</kbd> transposes the last two words.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">z</kbd>, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">_</kbd> (<kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">/</kbd> on some terminals) undo the most recent edit of the line.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">/</kbd> or <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">shift</kbd>-<kbd class="kbd docutils literal notranslate">z</kbd> reverts the most recent undo.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">r</kbd> opens the history in a pager. This will show history entries matching the search, a few at a time. Pressing <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">r</kbd> again will search older entries, pressing <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">s</kbd> (that otherwise toggles pager search) will go to newer entries. The search bar will always be selected.</p></li>
</ul>
<p>You can change these key bindings using the <a class="reference internal" href="cmds/bind.html"><span class="doc">bind</span></a> builtin.</p>
</section>
<section id="vi-mode-commands">
<span id="vi-mode"></span><h3>Vi mode commands<a class="headerlink" href="#vi-mode-commands" title="Link to this heading">¶</a></h3>
<p>Vi mode allows for the use of vi-like commands at the prompt. Initially, <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a> is active. <kbd class="kbd docutils literal notranslate">escape</kbd> enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>. The commands available in command, insert and visual mode are described below. Vi mode shares <a class="reference internal" href="#shared-binds"><span class="std std-ref">some bindings</span></a> with <a class="reference internal" href="#emacs-mode"><span class="std std-ref">Emacs mode</span></a>.</p>
<p>To enable vi mode, use <a class="reference internal" href="cmds/fish_vi_key_bindings.html"><span class="doc">fish_vi_key_bindings</span></a>.
It is also possible to add all Emacs mode bindings to vi mode by using something like:</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">fish_user_key_bindings</span>
<span class="w">    </span><span class="c"># Execute this once per mode that emacs bindings should be used in</span>
<span class="w">    </span><span class="nf">fish_default_key_bindings</span><span class="w"> </span><span class="no">-M</span><span class="w"> </span><span class="no">insert</span>

<span class="w">    </span><span class="c"># Then execute the vi-bindings so they take precedence when there&#39;s a conflict.</span>
<span class="w">    </span><span class="c"># Without --no-erase fish_vi_key_bindings will default to</span>
<span class="w">    </span><span class="c"># resetting all bindings.</span>
<span class="w">    </span><span class="c"># The argument specifies the initial mode (insert, &quot;default&quot; or visual).</span>
<span class="w">    </span><span class="nf">fish_vi_key_bindings</span><span class="w"> </span><span class="no">--no-erase</span><span class="w"> </span><span class="no">insert</span>
<span class="nf">end</span>
</pre></div>
</div>
<p>When in vi mode, the <a class="reference internal" href="cmds/fish_mode_prompt.html"><span class="doc">fish_mode_prompt</span></a> function will display a mode indicator to the left of the prompt. To disable this feature, override it with an empty function. To display the mode elsewhere (like in your right prompt), use the output of the <code class="docutils literal notranslate"><span class="pre">fish_default_mode_prompt</span></code> function.</p>
<p>When a binding switches the mode, it will repaint the mode-prompt if it exists, and the rest of the prompt only if it doesn’t. So if you want a mode-indicator in your <code class="docutils literal notranslate"><span class="pre">fish_prompt</span></code>, you need to erase <code class="docutils literal notranslate"><span class="pre">fish_mode_prompt</span></code> e.g. by adding an empty file at <code class="docutils literal notranslate"><span class="pre">~/.config/fish/functions/fish_mode_prompt.fish</span></code>. (Bindings that change the mode are supposed to call the <cite>repaint-mode</cite> bind function, see <a class="reference internal" href="cmds/bind.html"><span class="doc">bind</span></a>)</p>
<p>The <code class="docutils literal notranslate"><span class="pre">fish_vi_cursor</span></code> function will be used to change the cursor’s shape depending on the mode in supported terminals. The following snippet can be used to manually configure cursors after enabling vi mode:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="c"># Emulates vim&#39;s cursor shape behavior</span>
<span class="c"># Set the normal and visual mode cursors to a block</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_default</span><span class="w"> </span><span class="no">block</span>
<span class="c"># Set the insert mode cursor to a line</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_insert</span><span class="w"> </span><span class="no">line</span>
<span class="c"># Set the replace mode cursors to an underscore</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_replace_one</span><span class="w"> </span><span class="no">underscore</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_replace</span><span class="w"> </span><span class="no">underscore</span>
<span class="c"># Set the external cursor to a line. The external cursor appears when a command is started.</span>
<span class="c"># The cursor shape takes the value of fish_cursor_default when fish_cursor_external is not specified.</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_external</span><span class="w"> </span><span class="no">line</span>
<span class="c"># The following variable can be used to configure cursor shape in</span>
<span class="c"># visual mode, but due to fish_cursor_default, is redundant here</span>
<span class="nf">set</span><span class="w"> </span><span class="no">fish_cursor_visual</span><span class="w"> </span><span class="no">block</span>
</pre></div>
</div>
<p>Additionally, <code class="docutils literal notranslate"><span class="pre">blink</span></code> can be added after each of the cursor shape parameters to set a blinking cursor in the specified shape.</p>
<p>Fish knows the shapes “block”, “line” and “underscore”, other values will be ignored.</p>
<p>If the cursor shape does not appear to be changing after setting the above variables, it’s likely your terminal emulator does not support the capabilities necessary to do this.</p>
<section id="command-mode">
<span id="vi-mode-command"></span><h4>Command mode<a class="headerlink" href="#command-mode" title="Link to this heading">¶</a></h4>
<p>Command mode is also known as normal mode.</p>
<ul class="simple">
<li><p><kbd class="kbd docutils literal notranslate">h</kbd> moves the cursor left.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">l</kbd> moves the cursor right.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">k</kbd> and <kbd class="kbd docutils literal notranslate">j</kbd> search the command history for the previous/next command containing the string that was specified on the commandline before the search was started. If the commandline was empty when the search started, all commands match. See the <a class="reference internal" href="#history-search"><span class="std std-ref">history</span></a> section for more information on history searching. In multi-line commands, they move the cursor up and down respectively.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">i</kbd> enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a> at the current cursor position.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">I</kbd> enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a> at the beginning of the line.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">v</kbd> enters <a class="reference internal" href="#vi-mode-visual"><span class="std std-ref">visual mode</span></a> at the current cursor position.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">a</kbd> enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a> after the current cursor position.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">A</kbd> enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a> at the end of the line.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">o</kbd> inserts a new line under the current one and enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a></p></li>
<li><p><kbd class="kbd docutils literal notranslate">O</kbd> (capital-“o”) inserts a new line above the current one and enters <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a></p></li>
<li><p><kbd class="kbd docutils literal notranslate">0</kbd> (zero) moves the cursor to beginning of line (remaining in command mode).</p></li>
<li><p><kbd class="kbd docutils literal notranslate">d,d</kbd> deletes the current line and moves it to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">D</kbd> deletes text after the current cursor position and moves it to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">p</kbd> pastes text from the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">u</kbd> undoes the most recent edit of the command line.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">r</kbd> redoes the most recent edit.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">[</kbd> and <kbd class="kbd docutils literal notranslate">]</kbd> search the command history for the previous/next token containing the token under the cursor before the search was started. See the <a class="reference internal" href="#history-search"><span class="std std-ref">history</span></a> section for more information on history searching.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">/</kbd> opens the history in a pager. This will show history entries matching the search, a few at a time. Pressing it again will search older entries, pressing <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">s</kbd> (that otherwise toggles pager search) will go to newer entries. The search bar will always be selected.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">backspace</kbd> moves the cursor left.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">g,g</kbd> / <kbd class="kbd docutils literal notranslate">G</kbd> moves the cursor to the beginning/end of the commandline, respectively.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">~</kbd> toggles the case (upper/lower) of the character and moves to the next character.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">g,u</kbd> lowercases to the end of the word.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">g,U</kbd> uppercases to the end of the word.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">:,q</kbd> exits fish.</p></li>
</ul>
</section>
<section id="insert-mode">
<span id="vi-mode-insert"></span><h4>Insert mode<a class="headerlink" href="#insert-mode" title="Link to this heading">¶</a></h4>
<ul class="simple">
<li><p><kbd class="kbd docutils literal notranslate">escape</kbd> enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">backspace</kbd> removes one character to the left.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">n</kbd> accepts the autosuggestion.</p></li>
</ul>
</section>
<section id="visual-mode">
<span id="vi-mode-visual"></span><h4>Visual mode<a class="headerlink" href="#visual-mode" title="Link to this heading">¶</a></h4>
<ul class="simple">
<li><p><kbd class="kbd docutils literal notranslate">left</kbd> <kbd class="kbd docutils literal notranslate">(``←`</kbd>) and <kbd class="kbd docutils literal notranslate">right`(``→`</kbd>) extend the selection backward/forward by one character.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">h</kbd> moves the cursor left.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">l</kbd> moves the cursor right.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">k</kbd> moves the cursor up.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">j</kbd> moves the cursor down.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">b</kbd> and <kbd class="kbd docutils literal notranslate">w</kbd> extend the selection backward/forward by one word.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">d</kbd> and <kbd class="kbd docutils literal notranslate">x</kbd> move the selection to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a> and enter <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">escape</kbd> and <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">c</kbd> enter <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">c</kbd> and <kbd class="kbd docutils literal notranslate">s</kbd> remove the selection and switch to insert mode.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">X</kbd> moves the entire line to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">y</kbd> copies the selection to the <a class="reference internal" href="#killring"><span class="std std-ref">Copy and paste (Kill Ring)</span></a>, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">~</kbd> toggles the case (upper/lower) on the selection, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">g,u</kbd> lowercases the selection, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">g,U</kbd> uppercases the selection, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
<li><p><kbd class="kbd docutils literal notranslate">&quot;,*,y</kbd> copies the selection to the clipboard, and enters <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>.</p></li>
</ul>
</section>
</section>
<section id="custom-bindings">
<h3>Custom bindings<a class="headerlink" href="#custom-bindings" title="Link to this heading">¶</a></h3>
<p>In addition to the standard bindings listed here, you can also define your own with <a class="reference internal" href="cmds/bind.html"><span class="doc">bind</span></a>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="c"># Prints ``^C`` and a new prompt</span>
<span class="nf">bind</span><span class="w"> </span><span class="no">ctrl-c</span><span class="w"> </span><span class="no">cancel-commandline</span>
</pre></div>
</div>
<p>Put <code class="docutils literal notranslate"><span class="pre">bind</span></code> statements into <a class="reference internal" href="language.html#configuration"><span class="std std-ref">config.fish</span></a> or a function called <code class="docutils literal notranslate"><span class="pre">fish_user_key_bindings</span></code>.</p>
<p>If you change your mind on a binding and want to go back to fish’s default, you can erase it again:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">bind</span><span class="w"> </span><span class="no">--erase</span><span class="w"> </span><span class="no">ctrl-c</span>
</pre></div>
</div>
<p>Fish remembers its preset bindings and so it will take effect again. This saves you from having to remember what it was before and add it again yourself.</p>
<p>If you use <a class="reference internal" href="#vi-mode"><span class="std std-ref">vi bindings</span></a>, note that <code class="docutils literal notranslate"><span class="pre">bind</span></code> will by default bind keys in <a class="reference internal" href="#vi-mode-command"><span class="std std-ref">command mode</span></a>. To bind something in <a class="reference internal" href="#vi-mode-insert"><span class="std std-ref">insert mode</span></a>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">bind</span><span class="w"> </span><span class="no">--mode</span><span class="w"> </span><span class="no">insert</span><span class="w"> </span><span class="no">ctrl-c</span><span class="w"> </span><span class="s1">&#39;commandline -r &quot;&quot;&#39;</span>
</pre></div>
</div>
<section id="key-sequences">
<span id="interactive-key-sequences"></span><h4>Key sequences<a class="headerlink" href="#key-sequences" title="Link to this heading">¶</a></h4>
<p>To find out the name of a key, you can use <a class="reference internal" href="cmds/fish_key_reader.html"><span class="doc">fish_key_reader</span></a>.</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt; </span><span class="nf">fish_key_reader</span><span class="w"> </span><span class="c"># Press Alt + right-arrow</span>
<span class="go">Press a key:</span>
<span class="go">bind alt-right &#39;do something&#39;</span>
</pre></div>
</div>
<p>Note that the historical way the terminal encodes keys and sends them to the application (fish, in this case) makes a lot of combinations indistinguishable or unbindable. In the usual encoding, <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">i</kbd> <em>is the same</em> as the tab key, and shift cannot be detected when ctrl is also pressed.</p>
<p>There are more powerful encoding schemes, and fish tries to tell the terminal to turn them on, but there are still many terminals that do not support them. When <code class="docutils literal notranslate"><span class="pre">fish_key_reader</span></code> prints the same sequence for two different keys, then that is because your terminal sends the same sequence for them, and there isn’t anything fish can do about it. It is our hope that these schemes will become more widespread, making input more flexible.</p>
<p>In the historical scheme, <kbd class="kbd docutils literal notranslate">escape</kbd> is the same thing as <kbd class="kbd docutils literal notranslate">alt</kbd> in a terminal. To distinguish between pressing <kbd class="kbd docutils literal notranslate">escape</kbd> and then another key, and pressing <kbd class="kbd docutils literal notranslate">alt</kbd> and that key (or an escape sequence the key sends), fish waits for a certain time after seeing an escape character. This is configurable via the <span class="target" id="index-1"></span><a class="reference internal" href="language.html#envvar-fish_escape_delay_ms"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">fish_escape_delay_ms</span></code></a> variable.</p>
<p>If you want to be able to press <kbd class="kbd docutils literal notranslate">escape</kbd> and then a character and have it count as <kbd class="kbd docutils literal notranslate">alt</kbd>+that character, set it to a higher value, e.g.:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="nf">set</span><span class="w"> </span><span class="no">-g</span><span class="w"> </span><span class="no">fish_escape_delay_ms</span><span class="w"> </span><span class="no">100</span>
</pre></div>
</div>
<p>Similarly, to disambiguate <em>other</em> keypresses where you’ve bound a subsequence and a longer sequence, fish has <span class="target" id="index-2"></span><a class="reference internal" href="language.html#envvar-fish_sequence_key_delay_ms"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">fish_sequence_key_delay_ms</span></code></a>:</p>
<div class="highlight-fish-docs-samples notranslate"><div class="highlight"><pre><span></span><span class="c"># This binds the sequence j,k to switch to normal mode in vi mode.</span>
<span class="c"># If you kept it like that, every time you press &quot;j&quot;,</span>
<span class="c"># fish would wait for a &quot;k&quot; or other key to disambiguate</span>
<span class="nf">bind</span><span class="w"> </span><span class="no">-M</span><span class="w"> </span><span class="no">insert</span><span class="w"> </span><span class="no">-m</span><span class="w"> </span><span class="no">default</span><span class="w"> </span><span class="no">j,k</span><span class="w"> </span><span class="no">cancel</span><span class="w"> </span><span class="no">repaint-mode</span>

<span class="c"># After setting this, fish only waits 200ms for the &quot;k&quot;,</span>
<span class="c"># or decides to treat the &quot;j&quot; as a separate sequence, inserting it.</span>
<span class="nf">set</span><span class="w"> </span><span class="no">-g</span><span class="w"> </span><span class="no">fish_sequence_key_delay_ms</span><span class="w"> </span><span class="no">200</span>
</pre></div>
</div>
</section>
</section>
<section id="copy-and-paste-kill-ring">
<span id="killring"></span><h3>Copy and paste (Kill Ring)<a class="headerlink" href="#copy-and-paste-kill-ring" title="Link to this heading">¶</a></h3>
<p>Fish uses an Emacs-style kill ring for copy and paste functionality. For example, use <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">k</kbd> (<cite>kill-line</cite>) to cut from the current cursor position to the end of the line. The string that is cut (a.k.a. killed in emacs-ese) is inserted into a list of kills, called the kill ring. To paste the latest value from the kill ring (emacs calls this “yanking”) use <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">y</kbd> (the <code class="docutils literal notranslate"><span class="pre">yank</span></code> input function). After pasting, use <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">y</kbd> (<code class="docutils literal notranslate"><span class="pre">yank-pop</span></code>) to rotate to the previous kill.</p>
<p>Copy and paste from outside are also supported, both via the <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">x</kbd> / <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">v</kbd> bindings (the <code class="docutils literal notranslate"><span class="pre">fish_clipboard_copy</span></code> and <code class="docutils literal notranslate"><span class="pre">fish_clipboard_paste</span></code> functions <a class="footnote-reference brackets" href="#id10" id="id9" role="doc-noteref"><span class="fn-bracket">[</span>3<span class="fn-bracket">]</span></a>) and via the terminal’s paste function, for which fish enables “Bracketed Paste Mode”, so it can tell a paste from manually entered text.
In addition, when pasting inside single quotes, pasted single quotes and backslashes are automatically escaped so that the result can be used as a single token by closing the quote after.
Kill ring entries are stored in <code class="docutils literal notranslate"><span class="pre">fish_killring</span></code> variable.</p>
<p>The commands <code class="docutils literal notranslate"><span class="pre">begin-selection</span></code> and <code class="docutils literal notranslate"><span class="pre">end-selection</span></code> (unbound by default; used for selection in vi visual mode) control text selection together with cursor movement commands that extend the current selection.
The variable <span class="target" id="index-3"></span><a class="reference internal" href="language.html#envvar-fish_cursor_selection_mode"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">fish_cursor_selection_mode</span></code></a> can be used to configure if that selection should include the character under the cursor (<code class="docutils literal notranslate"><span class="pre">inclusive</span></code>) or not (<code class="docutils literal notranslate"><span class="pre">exclusive</span></code>). The default is <code class="docutils literal notranslate"><span class="pre">exclusive</span></code>, which works well with any cursor shape. For vi mode, and particularly for the <code class="docutils literal notranslate"><span class="pre">block</span></code> or <code class="docutils literal notranslate"><span class="pre">underscore</span></code> cursor shapes you may prefer <code class="docutils literal notranslate"><span class="pre">inclusive</span></code>.</p>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id10" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id9">3</a><span class="fn-bracket">]</span></span>
<p>These rely on external tools. Currently xsel, xclip, wl-copy/wl-paste and pbcopy/pbpaste are supported.</p>
</aside>
</aside>
</section>
<section id="multiline-editing">
<span id="multiline"></span><h3>Multiline editing<a class="headerlink" href="#multiline-editing" title="Link to this heading">¶</a></h3>
<p>The fish commandline editor can be used to work on commands that are several lines long. There are three ways to make a command span more than a single line:</p>
<ul class="simple">
<li><p>Pressing the <kbd class="kbd docutils literal notranslate">enter</kbd> key while a block of commands is unclosed, such as when one or more block commands such as <code class="docutils literal notranslate"><span class="pre">for</span></code>, <code class="docutils literal notranslate"><span class="pre">begin</span></code> or <code class="docutils literal notranslate"><span class="pre">if</span></code> do not have a corresponding <a class="reference internal" href="cmds/end.html"><span class="doc">end</span></a> command.</p></li>
<li><p>Pressing <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">enter</kbd> instead of pressing the <kbd class="kbd docutils literal notranslate">enter</kbd> key.</p></li>
<li><p>By inserting a backslash (<code class="docutils literal notranslate"><span class="pre">\</span></code>) character before pressing the <kbd class="kbd docutils literal notranslate">enter</kbd> key, escaping the newline.</p></li>
</ul>
<p>The fish commandline editor works exactly the same in single line mode and in multiline mode. To move between lines use the left and right arrow keys and other such keyboard shortcuts.</p>
</section>
<section id="searchable-command-history">
<span id="history-search"></span><h3>Searchable command history<a class="headerlink" href="#searchable-command-history" title="Link to this heading">¶</a></h3>
<p>After a command has been executed, it is remembered in the history list. Any duplicate history items are automatically removed. By pressing the up and down keys, you can search forwards and backwards in the history. If the current command line is not empty when starting a history search, only the commands containing the string entered into the command line are shown.</p>
<p>By pressing <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">up</kbd> (<code class="docutils literal notranslate"><span class="pre">↑</span></code>) and <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">down</kbd> (<code class="docutils literal notranslate"><span class="pre">↓</span></code>), a history search is also performed, but instead of searching for a complete commandline, each commandline is broken into separate elements like it would be before execution, and the history is searched for an element matching that under the cursor.</p>
<p>For more complicated searches, you can press <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">r</kbd> to open a pager that allows you to search the history. It shows a limited number of entries in one page, press <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">r</kbd> <a class="footnote-reference brackets" href="#id13" id="id11" role="doc-noteref"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></a> again to move to the next page and <kbd class="kbd docutils literal notranslate">ctrl</kbd>-<kbd class="kbd docutils literal notranslate">s</kbd> <a class="footnote-reference brackets" href="#id14" id="id12" role="doc-noteref"><span class="fn-bracket">[</span>5<span class="fn-bracket">]</span></a> to move to the previous page. You can change the text to refine your search.</p>
<p>History searches are case-insensitive unless the search string contains an uppercase character. You can stop a search to edit your search string by pressing <kbd class="kbd docutils literal notranslate">escape</kbd> or <kbd class="kbd docutils literal notranslate">pagedown</kbd>.</p>
<p>Prefixing the commandline with a space will prevent the entire line from being stored in the history. It will still be available for recall until the next command is executed, but will not be stored on disk. This is to allow you to fix misspellings and such.</p>
<p>The command history is stored in the file <code class="docutils literal notranslate"><span class="pre">~/.local/share/fish/fish_history</span></code> (or
<code class="docutils literal notranslate"><span class="pre">$XDG_DATA_HOME/fish/fish_history</span></code> if that variable is set) by default. However, you can set the
<code class="docutils literal notranslate"><span class="pre">fish_history</span></code> environment variable to change the name of the history session (resulting in a
<code class="docutils literal notranslate"><span class="pre">&lt;session&gt;_history</span></code> file); both before starting the shell and while the shell is running.</p>
<p>See the <a class="reference internal" href="cmds/history.html"><span class="doc">history</span></a> command for other manipulations.</p>
<p>Examples:</p>
<p>To search for previous entries containing the word ‘make’, type <code class="docutils literal notranslate"><span class="pre">make</span></code> in the console and press the up key.</p>
<p>If the commandline reads <code class="docutils literal notranslate"><span class="pre">cd</span> <span class="pre">m</span></code>, place the cursor over the <code class="docutils literal notranslate"><span class="pre">m</span></code> character and press <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">up</kbd> (<code class="docutils literal notranslate"><span class="pre">↑</span></code>) to search for previously typed words containing ‘m’.</p>
<aside class="footnote-list brackets">
<aside class="footnote brackets" id="id13" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id11">4</a><span class="fn-bracket">]</span></span>
<p>Or another binding that triggers the <code class="docutils literal notranslate"><span class="pre">history-pager</span></code> input function. See <a class="reference internal" href="cmds/bind.html"><span class="doc">bind</span></a> for a list.</p>
</aside>
<aside class="footnote brackets" id="id14" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#id12">5</a><span class="fn-bracket">]</span></span>
<p>Or another binding that triggers the <code class="docutils literal notranslate"><span class="pre">pager-toggle-search</span></code> input function.</p>
</aside>
</aside>
</section>
</section>
<section id="private-mode">
<span id="id15"></span><h2>Private mode<a class="headerlink" href="#private-mode" title="Link to this heading">¶</a></h2>
<p>Fish has a private mode, in which command history will not be written to the history file on disk. To enable it, either set <code class="docutils literal notranslate"><span class="pre">$fish_private_mode</span></code> to a non-empty value, or launch with <code class="docutils literal notranslate"><span class="pre">fish</span> <span class="pre">--private</span></code> (or <code class="docutils literal notranslate"><span class="pre">fish</span> <span class="pre">-P</span></code> for short).</p>
<p>If you launch fish with <code class="docutils literal notranslate"><span class="pre">-P</span></code>, it both hides old history and prevents writing history to disk. This is useful to avoid leaking personal information (e.g. for screencasts) or when dealing with sensitive information.</p>
<p>You can query the variable <code class="docutils literal notranslate"><span class="pre">fish_private_mode</span></code> (<code class="docutils literal notranslate"><span class="pre">if</span> <span class="pre">test</span> <span class="pre">-n</span> <span class="pre">&quot;$fish_private_mode&quot;</span> <span class="pre">...</span></code>) if you would like to respect the user’s wish for privacy and alter the behavior of your own fish scripts.</p>
</section>
<section id="navigating-directories">
<h2>Navigating directories<a class="headerlink" href="#navigating-directories" title="Link to this heading">¶</a></h2>
<p id="directory-history">Navigating directories is usually done with the <a class="reference internal" href="cmds/cd.html"><span class="doc">cd</span></a> command, but fish offers some advanced features as well.</p>
<p>The current working directory can be displayed with the <a class="reference internal" href="cmds/pwd.html"><span class="doc">pwd</span></a> command, or the <code class="docutils literal notranslate"><span class="pre">$PWD</span></code> <a class="reference internal" href="language.html#variables-special"><span class="std std-ref">special variable</span></a>. Usually your prompt already does this.</p>
<section id="id16">
<h3>Directory history<a class="headerlink" href="#id16" title="Link to this heading">¶</a></h3>
<p>Fish automatically keeps a trail of the recent visited directories with <a class="reference internal" href="cmds/cd.html"><span class="doc">cd</span></a> by storing this history in the <code class="docutils literal notranslate"><span class="pre">dirprev</span></code> and <code class="docutils literal notranslate"><span class="pre">dirnext</span></code> variables.</p>
<p>Several commands are provided to interact with this directory history:</p>
<ul class="simple">
<li><p><a class="reference internal" href="cmds/dirh.html"><span class="doc">dirh</span></a> prints the history</p></li>
<li><p><a class="reference internal" href="cmds/cdh.html"><span class="doc">cdh</span></a> displays a prompt to quickly navigate the history</p></li>
<li><p><a class="reference internal" href="cmds/prevd.html"><span class="doc">prevd</span></a> moves backward through the history. It is bound to <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">left</kbd> (<code class="docutils literal notranslate"><span class="pre">←</span></code>)</p></li>
<li><p><a class="reference internal" href="cmds/nextd.html"><span class="doc">nextd</span></a> moves forward through the history. It is bound to <kbd class="kbd docutils literal notranslate">alt</kbd>-<kbd class="kbd docutils literal notranslate">right</kbd> (<code class="docutils literal notranslate"><span class="pre">→</span></code>)</p></li>
</ul>
</section>
<section id="directory-stack">
<span id="id17"></span><h3>Directory stack<a class="headerlink" href="#directory-stack" title="Link to this heading">¶</a></h3>
<p>Another set of commands, usually also available in other shells like bash, deal with the directory stack. Stack handling is not automatic and needs explicit calls of the following commands:</p>
<ul class="simple">
<li><p><a class="reference internal" href="cmds/dirs.html"><span class="doc">dirs</span></a> prints the stack</p></li>
<li><p><a class="reference internal" href="cmds/pushd.html"><span class="doc">pushd</span></a> adds a directory on top of the stack and makes it the current working directory</p></li>
<li><p><a class="reference internal" href="cmds/popd.html"><span class="doc">popd</span></a> removes the directory on top of the stack and changes the current working directory</p></li>
</ul>
</section>
</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-this"><a href="">Interactive use</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>