main
1<!DOCTYPE html>
2<html lang="en">
3<head>
4<!-- Oct 07, 2022 -->
5<meta charset="utf-8" />
6<meta name="viewport" content="width=device-width, initial-scale=1" />
7<title>Fish shell notes</title>
8<meta name="author" content="Vincent Demeester" />
9<meta name="keywords" content="article" />
10<meta name="generator" content="Org Mode" />
11<link rel='icon' type='image/x-icon' href='/images/favicon.ico'/>
12<meta name='viewport' content='width=device-width, initial-scale=1'>
13<link rel='stylesheet' href='/css/new.css' type='text/css'/>
14<link rel='stylesheet' href='/css/syntax.css' type='text/css'/>
15<link href='/index.xml' rel='alternate' type='application/rss+xml' title='Vincent Demeester' />
16</head>
17<body>
18<main id="content" class="content">
19<header>
20<h1 class="title">Fish shell notes</h1>
21</header><p>
22I recently (2017) switch to <a href="https://fishshell.com/">fish</a> shell as my interactive shell. There
23is a few reason for it:
24</p>
25
26<ul class="org-ul">
27<li>the defaults are really good and there is a little to configure to
28achieve what I was trying to do with zsh,</li>
29<li>the autosuggestion feature is quite cool (I even went to reproduce
30that in <code>eshell</code>),</li>
31<li>the syntax highlighting feature is also killer as it easier to see
32problems in the command-line before hitting enter,</li>
33<li><p>
34it auto-generates completion from parsing man pages <code><3</code>
35</p>
36
37<div class="org-src-container">
38<pre class="src src-sh">$ fish_update_completions
39Parsing man pages and writing completions to /home/vincent/.local/share/fish/generated_completions/
40 1793 / 1793 : zramctl.8.gz
41</pre>
42</div></li>
43</ul>
44
45<p>
46At the begining, I used <a href="https://github.com/oh-my-fish/oh-my-fish">oh-my-fish</a> as a simple way in.
47</p>
48
49<blockquote>
50<p>
51Oh My Fish provides core infrastructure to allow you to install
52packages which extend or modify the look of your shell. It’s fast,
53extensible and easy to use.
54</p>
55</blockquote>
56
57<p>
58<a href="https://github.com/oh-my-fish/oh-my-fish">oh-my-fish</a> is pretty cool but I tend to use only a few plugin and I
59almost have more hand-written configuration files for fish than what
60oh-my-fish gives me. So I’m now using <a href="https://fishshell.com/">fish</a> shell <i>bare-naked</i> with my
61own configurations.
62</p>
63
64<p>
65According to the <a href="https://fishshell.com/docs/current/index.html#initialization">documentation</a>, fish will load files from the
66following folder (in order):
67</p>
68
69<ul class="org-ul">
70<li>Configuration shipped with fish, which should not be edited, in
71<code>$__fish_datadir/config.fish</code> (usually <code>/usr/share/fish/config.fish</code>).</li>
72<li>System-wide configuration files, where administrators can include
73initialization that should be run for all users on the system -
74similar to <code>/etc/profile</code> for POSIX-style shells - in
75<code>$__fish_sysconfdir</code> (usually <code>/etc/fish/config.fish</code>);</li>
76<li><p>
77Configuration snippets in files ending in <code>.fish</code>, in the directories:
78</p>
79<ul class="org-ul">
80<li><code>$XDG_CONFIG_HOME/fish/conf.d</code> (by default, <code>~/.config/fish/conf.d/</code>)</li>
81<li><code>$__fish_sysconfdir/conf.d</code> (by default, <code>/etc/fish/conf.d</code>)</li>
82<li><code>/usr/share/fish/vendor_conf.d</code> (set at compile time; by default,
83<code>$__fish_datadir/conf.d</code>)</li>
84</ul>
85<p>
86If there are multiple files with the same name in these directories,
87only the first will be executed. They are executed in order of their
88filename, sorted (like globs) in a natural order (i.e. “01” sorts
89before “2”).
90</p></li>
91<li>User initialization, usually in <code>~/.config/fish/config.fish</code>
92(controlled by the <code>XDG_CONFIG_HOME</code> environment variable).</li>
93</ul>
94
95<p>
96Fish will also automatically loads functions from the following folder
97(in order):
98</p>
99
100<ul class="org-ul">
101<li>A directory for end-users to keep their own functions, usually
102<code>~/.config/fish/functions</code> (controlled by the <code>XDG_CONFIG_HOME</code>
103environment variable).</li>
104<li>A directory for systems administrators to install functions for all
105users on the system, usually <code>/etc/fish/functions</code>.</li>
106<li>A directory for third-party software vendors to ship their own
107functions for their software, usually
108<code>/usr/share/fish/vendor_functions.d</code>.</li>
109<li>The functions shipped with fish, usually installed in
110<code>/usr/share/fish/functions</code>.</li>
111</ul>
112
113<blockquote>
114<p>
115An autoloaded function becomes available automatically to all
116running shells. If the function definition is changed, all running
117shells will automatically reload the altered version. Startup time and
118memory usage is improved, etc.
119</p>
120</blockquote>
121
122<p>
123I’m also using <a href="https://nixos.org/">nixos</a> which have some specificities but we’ll see that
124later. One specificity though about my setup is the, I may want some
125fish function/helper to be available for all users on a server (when
126using nixos) or only a user (mainly, when using nixpkgs without nixos,
127on Mac OSX or another linux or on Windows with WSL).
128</p>
129</main>
130<footer id="postamble" class="status">
131<footer>
132 <small><a href="/" rel="history">Index</a> • <a href="/sitemap.html">Sitemap</a> • <a href="https://dl.sbr.pm/">Files</a></small><br/>
133 <small class='questions'>Questions, comments ? Please use my <a href="https://lists.sr.ht/~vdemeester/public-inbox">public inbox</a> by sending a plain-text email to <a href="mailto:~vdemeester/public-inbox@lists.sr.ht">~vdemeester/public-inbox@lists.sr.ht</a>.</small><br/>
134 <small class='copyright'>
135 Content and design by Vincent Demeester
136 (<a rel='licence' href='http://creativecommons.org/licenses/by-nc-sa/3.0/'>Some rights reserved</a>)
137 </small><br />
138</footer>
139</footer>
140</body>
141</html>