counter easy hit

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

Bash vs. Fish? I've tried both Linux shells, and one makes using the command line much easier
8
fishhero
Jack Wallen/ZDNET

Follow ZDNET: Add us as a preferred source on Google.


ZDNET’s key takeaways

  • The Linux shell enables communication with the kernel.
  • The default shell for most distributions is Bash.
  • There’s a much more user-friendly option, called Fish.

Essentially, the Linux shell interprets commands so the kernel can understand and use them. Without the shell, not only would commands not work, but applications wouldn’t work.

So, yes, the shell is very important.

Most Linux distributions default to the Bash shell, which stands for Bourne Again Shell. Why “Bourne”? Because Bourne shell was the first shell, and Bash is an improvement on that. With Bash, you can write bash scripts that can do just about anything. However, Bash has been around for a very long time, and it really hasn’t changed much.

Also: I joyfully reunited with my first Linux distro at the Virtual OS Museum

The good news is that there are alternatives, and one of those alternatives adds features that Bash has neglected. That shell is called Fish (Friendly Interactive SHell). The big difference between Bash and Fish is that Bash feels like it works for you, and Fish feels like it works with you.

That might not make sense at first, but let me explain.

The difference between Bash and Fish

When you run a command in Bash, you type it, hit Enter, and wait to see if it worked. Bash doesn’t help you; it just accepts the command and attempts to run it. That’s it.

Fish behaves a bit differently. When you start to type a command in Fish, it will offer suggestions (based on your history). When you see a suggestion that works for you, hit the right-pointing arrow key to accept a suggestion. For example, you might type ssh, and Fish will then present a suggestion like ssh 192.168.1.26. Hit the arrow key and then hit Enter.

Also: The first 5 Linux commands every new user should learn

You might also notice that Fish uses colors. For example, if you type an invalid command, Fish will color it red. If you alter an invalid command to make it valid, it turns blue.

If you start typing a file path, it’ll appear red, and as soon as the path is valid, it’ll turn blue.

When you start typing a command, pressing Tab will display several suggestions. You can then use your arrow keys to scroll through the list and select the command you want to run.

You can also set variables in Fish with the set command. For example, if I want to set a variable called name to my name, I could type:

set name jack

Now, I can use that variable like this:

echo “My name is $name”

Also: Why Wave is my new go-to terminal app – how I use this powerful tool

The response will be:

My name is jack

Fish is user-friendly in other ways. For instance, in Bash, you use back ticks (`) to indicate a command, which can often be confusing. In Fish, commands are placed in parentheses like this:

echo (whoami) in (pwd)

The results of the above command would be:

jack in /home/jack

You can also set abbreviations for commands (similar to aliases in Bash). Let’s say you use the git checkout command a lot and want to make it a bit more efficient. If you want to create the abbreviation gco for that command, it would be:

abbr –add gco git checkout

Or you could set several ssh abbreviations, like so:

abbr –add ssh11 “ssh 192.168.1.11”
abbr –add ssh12 “ssh 192.168.1.12”

Now, when you type ssh11, you’ll connect to 192.168.1.11, and if you type ssh12, you’ll connect to 192.168.1.12.

Also: The best Linux distros for beginners

Those abbreviations remain, even after logging out.

Fish also includes a handy calculator. For example, you could type:

math 5020/220

The answer (22.818182) will be presented at the prompt.

Installing and setting the Fish shell

Fish can be installed from your distribution’s standard repositories. For example, in Ubuntu, the command to install Fish would be:

sudo apt-get install fish -y

On Fedora, that command is:

sudo dnf install fish -y

On Arch, the command is:

sudo pacman -S fish

Once you’ve installed Fish, you must set it as the default shell with the command:

chsh -s $(which fish)

Also: 5 surprisingly productive things you can do with the Linux terminal

If you wind up not liking Fish (you will), you can change it back to Bash with:

chsh -s $(which bash)

And that’s the Fish shell. Remember, if you teach someone to Fish… you empower them for a lifetime.

Linux

Leave A Reply

Your email address will not be published.