Are you desperate for the freshest fish? Well, you’ve come to the right place.

Tutorial

The instructions herein describe how to install a much newer version of the fish shell, version 3.1.2, from source on CentOS 7. Further instructions for building fish are available from the fish documentation. For this tutorial to make a lick of sense, you should be familiar with the command-line, Linux, installing packages, and building projects from source.

  1. If you aren’t using the DNF package manager yet, grab that.

    sudo yum -y install dnf
  2. Add the EPEL repository for retrieving necessary dependencies.

    sudo dnf -y install \
      https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
  3. Install the build dependencies.

    sudo dnf -y install cmake3 gettext-devel git ncurses-devel ninja-build \
      pcre2-devel
  4. Pull down the fish repository.

    ➜ git clone https://github.com/fish-shell/fish-shell.git
  5. Checkout the latest release tag.

    ➜ git -C fish-shell switch --detach (git -C fish-shell describe --abbrev=0 --tags)
    HEAD is now at 0314b0f1d Release 3.1.2
  6. Configure CMake in the directory fish-shell/build.

    ➜ cmake3 -GNinja -B fish-shell/build -S fish-shell
  7. Build fish.

    ➜ cmake3 --build fish-shell/build
  8. Install fish.

    sudo cmake3 --install fish-shell/build
    -- Install configuration: "RelWithDebInfo"
  9. Register the shell in /etc/shells.

    echo /usr/local/bin/fish | sudo tee -a /etc/shells
    /usr/local/bin/fish
  10. Change your login shell to fish.

    ➜ chsh -s /usr/local/bin/fish
    Changing shell for jordan.
    Password:
    Shell changed.
  11. Log out and back in to complete the switch to fish.

  12. Because it is CentOS, add /usr/local/bin to your PATH.

    set -pU fish_user_paths /usr/local/bin

Update

To update to the latest version of fish, just checkout the latest version release, build, and install. For completeness, the instructions to update fish are provided below.

  1. Checkout the latest release tag.

    ➜ git -C fish-shell switch --detach (git -C fish-shell describe --abbrev=0 --tags)
    HEAD is now at 0314b0f1d Release 3.1.2
  2. Configure CMake in the directory fish-shell/build.

    ➜ cmake3 -GNinja -B fish-shell/build -S fish-shell
  3. Build fish.

    ➜ cmake3 --build fish-shell/build
  4. Install fish.

    sudo cmake3 --install fish-shell/build
    -- Install configuration: "RelWithDebInfo"

Troubleshooting

Packages on CentOS 7 might assume you are using a Bash-compatible login shell. For instance, the Qt 5 development packages work fine when using a Bash shell. After switching to fish, building a Qt 5 application failed because it could not find the xcb plugin. Setting the QT_QPA_PLATFORM_PLUGIN_PATH to as shown below resolved this issue.

set -Ux QT_QPA_PLATFORM_PLUGIN_PATH /usr/lib64/qt5/plugins/platforms

The moral of the story is to check any Bash-specific initialization in places such as the /etc/profile file and the /etc/profile.d directory. Otherwise, it’s entirely possible to use Bash as she login shell and and just execute fish from your ~/.bashrc initialization file. There’s also a fish plugin called Bass which can handle sourcing Bash files such as /etc/profile directly. Refer to the fish page’s section Alternative to fish as the login shell on the Gentoo Wiki for the exact implementation details for these workarounds.

Conclusion

You should notice enhanced cognitive performance from the incredible omega-3 fatty acid profile that only the freshest fish has to offer!