Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fedora - Fish – A Friendly Interactive Shell

#1
Fish – A Friendly Interactive Shell

<div style="margin: 5px 5% 10px 5%;"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell.png" width="383" height="43" title="" alt="" /></div><div><p>Are you looking for an alternative to bash? Are you looking for something more user-friendly? Then look no further because you just found the golden fish!</p>
<p>Fish (friendly interactive shell) is a smart and user-friendly command line shell that works on Linux, MacOS, and other operating systems. Use it for everyday work in your terminal and for scripting. Scripts written in fish are less cryptic than their equivalent bash versions.</p>
<h2>Fish’s user-friendly features</h2>
<ul>
<li><strong>Suggestions</strong> <br />Fish will suggest commands that you have written before. This boosts productivity when typing same commands often.</li>
<li><strong>Sane scripting</strong><br />Fish avoids using cryptic characters. This provides a clearer and friendlier syntax.</li>
<li><strong>Completion based on man pages</strong><br />Fish will autocomplete parameters based on the the command’s man page.</li>
<li><strong>Syntax highlighting</strong><br />Fish will highlight command syntax to make it visually friendly.</li>
</ul>
<h2>Installation</h2>
<h3>Fedora Workstation</h3>
<p>Use the <em>dnf</em> command to install fish:</p>
<pre class="wp-block-preformatted">$ sudo dnf install fish</pre>
<p>Make fish your default shell by installing the <em>util-linux-user</em> package and then running the <em>chsh</em> (change shell) command with the appropriate parameters:</p>
<pre class="wp-block-preformatted">$ sudo dnf install util-linux-user
$ chsh -s /usr/bin/fish</pre>
<p>You will need to log out and back in for this change to take effect.</p>
<h3>Fedora Silverblue</h3>
<p>Because this is not GUI application, you will need to layer it using <em>rpm-ostree</em>. Use the following command to install fish on Fedora Silverblue:</p>
<pre class="wp-block-preformatted">$ rpm-ostree install fish</pre>
<p>On Fedora Silverblue you will need to reboot your PC to switch to the new ostree image.</p>
<p>If you want to make fish your main shell on Fedora Silverblue, the easiest way is to update the <em>/etc/passwd</em> file. Find your user and change <em>/bin/bash</em> to <em>/usr/bin/fish</em>.</p>
<p>You will need <a href="https://fedoramagazine.org/howto-use-sudo/" target="_blank" rel="noreferrer noopener" aria-label="root privileges (opens in a new tab)">root privileges</a> to edit the <em>/etc/passwd</em> file. Also you will need to log out and back in for this change to take effect.</p>
<h2>Configuration</h2>
<p>The per-user configuration file for fish is <em>~/.config/fish/config.fish</em>. To make configuration changes for all users, edit <em>/etc/fish/config.fish</em> instead.</p>
<p>The per-user configuration file must be created manually. The installation scripts will not create <em>~/.config/fish/config.fish</em>.</p>
<p>Here are a couple configuration examples shown alongside their bash equivalents to get you started:</p>
<h3>Creating aliases</h3>
<ul>
<li><em>~/.bashrc</em>:
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">alias ll=’ls -lh’</div>
</div>
</li>
<li><em>~/.config/fish/config.fish</em>:
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">alias ll=’ls -lh’</div>
</div>
</li>
</ul>
<h3>Setting environment variables</h3>
<ul>
<li><em>~/.bashrc</em>:
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">export PATH=$PATH:~/bin</div>
</div>
</li>
<li><em>~/.config/fish/config.fish</em>:
<div class="codecolorer-container text default" style="overflow:auto;border:1px solid #9F9F9F;width:435px">
<div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace">set -gx PATH $PATH ~/bin</div>
</div>
</li>
</ul>
<h2>Working with fish</h2>
<p>When fish is configured as your default shell, the command prompt will look similar to what is shown in the below image. If you haven’t configured fish to be your default shell, just run the <em>fish</em> command to start it in your current terminal session.</p>
<figure class="wp-block-image size-large"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell.png" alt="" class="wp-image-30635" /></figure>
<p>As you start typing commands, you will notice the syntax highlighting:</p>
<figure class="wp-block-image size-large is-style-default"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell-1.png" alt="" class="wp-image-30636" /></figure>
<p>Cool, isn’t it? <img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell-2.png" alt="?" class="wp-smiley" style="height: 1em;max-height: 1em" /></p>
<p>You will also see commands being suggested as you type. For example, start typing the previous command a second time:</p>
<figure class="wp-block-image size-large"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell-3.png" alt="" class="wp-image-30637" /></figure>
<p>Notice the gray text that appears as you type. The gray text is fish suggesting the command you wrote before. To autocomplete it, just press <strong>CTRL+F</strong>.</p>
<p>Get argument suggestions based on the preceding command’s man page by typing a dash (<strong>–</strong>) and then the <strong>TAB</strong> key:</p>
<figure class="wp-block-image size-large is-style-default"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell-4.png" alt="" class="wp-image-30641" /></figure>
<p>If you press <strong>TAB</strong> once, it will show you the first few suggestions (or every suggestion, if there are only a few arguments available). If you press <strong>TAB</strong> a second time, it will show you all suggestions. If you press <strong>TAB</strong> three times consecutively, it will switch to interactive mode and you can select an argument using the arrow keys.</p>
<p>Otherwise, fish works similar to most other shells. The remaining differences are well documented. So it shouldn’t be difficult to find other features that you may be interested in.</p>
<h2>Make fish even more powerful</h2>
<p>Make the fish even more powerful with <a rel="noreferrer noopener" aria-label=" (opens in a new tab)" href="https://github.com/oh-my-fish/theme-bobthefish" target="_blank">powerline</a>. Powerline adds command execution time, colored git status, current git branch and much more to fish’s interface.</p>
<p>Before installing powerline for fish, you must install <a href="https://github.com/oh-my-fish/oh-my-fish" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Oh My Fish</a>. Oh My Fish extends fish’s core infrastructure to enable the installation of additional plugins. The easiest way to install Oh My Fish is to use the <em>curl</em> command:</p>
<pre class="wp-block-preformatted">&gt; curl -L https://get.oh-my.fish | fish</pre>
<p>If you don’t want to pipe the installation commands directly to <em>curl</em>, see the installation section of Oh My Fish’s <a href="https://github.com/oh-my-fish/oh-my-fish/blob/master/README.md#installation" target="_blank" rel="noreferrer noopener" aria-label="README (opens in a new tab)">README</a> for alternative installation methods.</p>
<p>Fish’s powerline plugin is <a href="https://github.com/oh-my-fish/theme-bobthefish" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">bobthefish</a>. Bobthefish requires the <em>powerline-fonts</em> package.</p>
<p><strong>On Fedora Workstation</strong>:</p>
<pre class="wp-block-preformatted">&gt; sudo dnf install powerline-fonts</pre>
<p><strong>On Fedora Silverblue</strong>:</p>
<pre class="wp-block-preformatted">&gt; rpm-ostree install powerline-fonts</pre>
<p>On Fedora Silverblue you will have to reboot to complete the installation of the fonts.</p>
<p>After you have installed the <em>powerline-fonts</em> package, install <em>bobthefish</em>:</p>
<pre class="wp-block-preformatted">&gt; omf install bobthefish</pre>
<p>Now you can experience the full awesomeness of fish with powerline:</p>
<figure class="wp-block-image size-large"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2020/03/fish-a-friendly-interactive-shell-5.png" alt="" class="wp-image-30643" /></figure>
<h2>Additional resources</h2>
<p>Check out these web pages to learn even more about fish:</p>
<ul>
<li><a href="https://fishshell.com/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Official page</a></li>
<li><a href="https://fishshell.com/docs/current/index.html" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Documentation</a></li>
<li><a href="https://fishshell.com/docs/current/tutorial.html" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Tutorial</a></li>
<li><a href="https://fishshell.com/docs/current/faq.html" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">FAQ</a></li>
<li><a href="https://rootnroll.com/d/fish-shell/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Web playground</a></li>
<li><a href="https://sourceforge.net/projects/fish/lists/fish-users" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Mailing lists</a></li>
<li><a href="https://github.com/fish-shell/fish-shell/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">GitHub</a></li>
</ul>
</div>


https://www.sickgaming.net/blog/2020/03/...ive-shell/
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016