Fish shell

Fish shell user introduction

I have been usingFish shellFor months, I think this is the best shell I have ever used. Because of many reasons.

People seem to insistThumpThis is the default setting on many systems (update: now, macOS’s default setting is Zsh) or use Zsh and use great tools such asOh my ZshMake it even more amazing.

Although Bash is great, it is a very basic shell with a limited set of configurable options. I tend to use it mainly for runningBash script(This is another topic), not as an interactive shell. Zsh provides many functions, but some configuration is required to set it up, which may make beginners feel scared. In addition, too many options and degrees of freedom mean that you can easily fall into configuration paralysis, and eventually have to change options 20 times a week to ensure that you don't miss any opportunities.

I don't want to be "confusing" on those projects. It's amazing. I spent a lot of time and still use it sometimes. This description is my attempt to emphasize the benefits of fish

The fish shell comes to the rescue! The enclosure provides an amazing environment and has a fully functional configuration out of the box.

Fish's favorite features are:

  • It provides a better auto-completion function for the commands you have executed, and this alone can make my daily work faster and more labor-saving.
  • You start typing a command and then pressupKey to view all the times in the shell history of your previous use of the command.
  • You can install Fish on any system, and Fish can work in the same way anywhere without having to do too much customization to get beautiful things.

In terms of scripting, it is completely different from Bash script (to be better IMHO), but you can run any Bash script prefixed with Bash script.#!/bin/bash.

After the installation is complete, you will get the following benefits:

  • Syntax highlighting
  • A good tip
  • Autocomplete
  • Parameter suggestions suggested in the man page
  • Web-based configuration

I think this is the best shell for beginners.

I remember one of the interesting things I noticed was the homepage. At first, I didn’t know if it was a relic of the past:

For those lucky ones who have a graphics computer, you can set colors and view functions, variables, and history from a web page.

Then I realized that this was programmer humor, which made me laugh. Technology should always be fun, right?

First of all, what is a shell?

Shell is the interface of the basic operating system. It allows you to perform operations using text and commands, and provides users with advanced features, such as the ability to create scripts.


Install Fish by runningbrew install fishOn macOS.

Look at minemacOS terminal guide

fishinstalled at/usr/local/bin/fish.

Since this is probably already in your path, runfishStart fish shell (typeexitReturn to your default shell)


The good thing about Fish is the web-based configuration. runfish_configStart the web client.


From here you can

  • Choose a color scheme from a list of predefined colors
  • Select a reminder from a list of predefined reminders
  • Check the configured Fish functions and variables
  • View command history

The configuration is stored in~/.config/fishFolder, you can edit in it without having to use the (optional) web-based configuration.

Fish function: syntax highlighting, auto-completion and parameter suggestions with manual page prompts

Fish enables you to execute regular Unix commands available on the system. File system operations, such as:

  • lsList files
  • cdChange folder
  • rmDelete files or folders
  • mvMove the file to another folder, or change the file name
  • cpCopy files

If you run one of these commands (oranyCommand, actually) and you will start to see the words you type in different colors. It makes it very easy to read and understand commands.

The fish can also increase the automatic completion function. If you runcd ~/.config/fish/Before, now you typecd, Fish will prompt you for commands that you might want to type, you just need to press the right arrow to accept the suggestion (or you can continue typing to change the command). This recommendation is based on the command history and file path.

Recommendations based on auto-completion also apply to commands. I enter herecAnd press the tab:

autocomplete commands

Fish also suggests parameters and how to use them. Types ofls -then presstab. The list of parameters you can use and their meanings is as follows:


This inline help is fromMan page, Useful shell help (try to runman lsFor complete help).

Set Fish as the default shell

If you like Fish and try to set it as the default shell, please open the file/etc/shells. I usepicoDo those small file editspico /etc/shells, But you can use any editor you like, and you can even combine VS Code withcode /etc/shells.

It should contain content similar to the following:

# List of acceptable shells for chpass(1).
# Ftpd will not allow users to connect who are not using
# one of these shells.

/bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh

Add the following line at the end to add the Fish shell:


next, run

chsh -s /usr/local/bin/fish

enter your password, and the shell will change for your user.

change shell


You can install Fish plugins.

Fisher is a popular Fish package manager.

Install it using

curl --create-dirs -sLo ~/.config/fish/functions/

and it’s available with the fisher command.

Now a package can be installed using fisher add <github-repository-path> and removed using fisher rm <github-repository-path>.

List all plugins installed using fisher ls.

Run fisher to update all the packages you installed.

Popular plugins are

Here is a list of packages you can install.

POSIX compliance

Various shells comply with the POSIX shell command standard.

POSIX means

  • Portable
  • Operating
  • System
  • Interface
  • X (for Unix)

and it’s a standard meant to unify the various Unix environment that were built over time. There is a shell command standard subset, which is meant as a way to unify how Unix shells work.

Unix is a specification/standard for a family of operating systems. Linux and macOS are based on Unix (Windows is not).

bash, ksh and others are POSIX compliant. Being POSIX compliant makes scripts written with POSIX compatibility work across POSIX compliant shells.

Fish (like sh or csh for example) is not compliant, so it’s not a POSIX shell, and this means that writing commands and scripts for Fish is different. Scripts written for Fish won’t work outside of Fish. Just like csh scripts only work on csh (and derivatives)

Why is it different? Various reasons, but I imagine having to support POSIX means the shell must adhere to a common language that might interfere with the shell philosophy and way of working. Not everyone want to have that baggage of tech to support forever.

This will very rarely be a problem with executing commands, but you need to keep it in mind when it comes to scripting and programming.

Download my free Linux Commands Handbook

More cli tutorials: