Bash vs. Fish? I've tried both Linux shells, and one makes using the command line much easier
Back to Tutorials
techTutorialbeginner

Bash vs. Fish? I've tried both Linux shells, and one makes using the command line much easier

May 26, 20266 views4 min read

Learn how to install and use Fish shell on Linux, making command-line usage more user-friendly with auto-completion and syntax highlighting.

Introduction

Have you ever found yourself struggling with the command line on Linux? You're not alone! Many users switch between different shells, and one that's gaining popularity is Fish (Friendly Interactive Shell). Unlike the traditional Bash shell, Fish offers features like auto-completion, syntax highlighting, and a more intuitive interface. In this tutorial, you'll learn how to install and use Fish shell on your Linux system, making your command-line experience much more enjoyable and efficient.

Prerequisites

  • A Linux system (Ubuntu, Debian, Fedora, or similar)
  • Basic understanding of using the terminal
  • Internet connection for downloading packages

Step 1: Check Your Current Shell

Before installing Fish, let's first see what shell you're currently using:

echo $SHELL

This command will display your current shell path. Most likely, it will show something like /bin/bash or /usr/bin/bash. This information helps us confirm that we're making the switch correctly.

Step 2: Install Fish Shell

For Ubuntu/Debian-based systems:

sudo apt update
sudo apt install fish

These commands update your package list and install Fish shell. The apt update ensures you have the latest package information, while apt install fish downloads and installs Fish.

For Fedora/CentOS/RHEL-based systems:

sudo dnf install fish

On Red Hat-based systems, we use dnf (Dandified YUM) to install Fish.

Step 3: Verify Fish Installation

After installation, verify that Fish is properly installed:

fish --version

This command should display the Fish version number, confirming that the installation was successful.

Step 4: Switch to Fish Shell

Now, let's switch your default shell to Fish:

chsh -s /usr/bin/fish

The chsh command changes your default shell, and -s specifies the shell path. This command updates your user account to use Fish as the default shell.

Step 5: Restart Your Terminal

After changing your shell, you need to restart your terminal or open a new one for the changes to take effect:

  • Close your current terminal window
  • Open a new terminal window
  • Or, in some cases, you can simply type exec fish in your current terminal

When you open a new terminal, you should see a welcome message from Fish and a different prompt style.

Step 6: Explore Fish Features

Try Auto-completion:

One of Fish's best features is its auto-completion. Try typing:

ls /ho

As you type, Fish will automatically suggest completions. Press Tab to cycle through options or press Enter to select one.

Try Syntax Highlighting:

Notice how Fish colors different parts of your commands. Try typing a simple command:

ls -la /home

You'll see that Fish highlights different parts of your command in different colors, making it easier to read and understand.

Step 7: Configure Fish (Optional)

While Fish works great out of the box, you can customize it further:

fish_config

This command opens a web-based configuration interface in your browser. Here you can customize colors, set up key bindings, and adjust other preferences.

Step 8: Test Fish Commands

Try some basic Fish commands to get comfortable:

echo "Hello Fish!"
fish --version
which fish

These commands test that Fish is working correctly and show you how to check Fish's version and location.

Step 9: Return to Bash (If Needed)

If you decide Fish isn't for you, you can easily switch back to Bash:

chsh -s /bin/bash

This command changes your shell back to Bash. Remember to restart your terminal after making this change.

Summary

In this tutorial, you've learned how to install and switch to Fish shell on your Linux system. You've explored Fish's key features like auto-completion and syntax highlighting, and practiced using basic commands. Fish makes the command line more user-friendly and efficient, especially for beginners. The installation process is straightforward, and switching between shells is simple. Whether you're a new Linux user or an experienced one looking for a better shell experience, Fish is definitely worth trying.

Remember, the command line can be intimidating at first, but with tools like Fish, it becomes much more approachable and even enjoyable. Start with Fish and see how it changes your Linux workflow!

Source: ZDNet AI

Related Articles