Fish is the Bash alternative all beginner programmers should use


Everything you do on the Linux command line involves a shell, whether you pay it any mind or not. It’s probably Bash, possibly Zsh, but either way, it’s highly relevant to all shell scripting, big and small.

The Fish shell is an alternative, with some particularly exciting features for programmers. Even if you’re just coding-curious, you can benefit from checking out this intriguing shell.

What is Fish, and how do you start using it?

A friendly, interactive shell that goes beyond POSIX

Fish is an often-overlooked shell, mainly because it’s usually not the default. CachyOS—a distro which has, admittedly, gained a lot of recent interest, is a rare exception.

CachyOS terminal.

Changing your shell is an easy process, but discoverability and familiarity are likely factors in most of us sticking to Bash or Zsh. But a shell is fundamental to running and scripting terminal commands, so it’s worth learning a bit about it; the benefits you feel should be widespread.

Just like every other shell, Fish has its own scripting language built in. A shell scripting language is usually easy to learn and use, partly because it’s just an extension of your typical command-line use.

Fish also comes packed with beginner-friendly features from syntax highlighting and autocomplete to web-based configuration and a super-powered version of the standard alias, called abbreviations.

Unlike shells such as Bash and Zsh, Fish does not follow the POSIX standard. That means that Fish scripts won’t necessarily run correctly in other shells, so if you’re building software for a wide audience, you’ll need to bear this in mind. For all your personal work, however, Fish is a perfect fit.

To start using Fish, begin by installing it with Homebrew (Mac) and brew install fish, pacman (Arch) and pacman -S fish, dnf (Fedora) and dnf install fish, or whichever method is appropriate for your system.

Once installed, you can try it out just by running the command fish. To make the change permanent, either use the chsh command or your system’s GUI equivalent.

The macOS System Settings app showing user details with a Login shell menu showing /bin/bash, /bin/csh, and other options.

Fish is beginner-friendly

Everyone benefits from Fish’s usability, even experienced users

The first thing you’ll notice upon starting Fish is its friendly welcome message and unique prompt:

A terminal showing the fish command printing a message reading "Welcome to fish, the friendly interactive shell."

However, as soon as you start interacting with the shell, you’ll notice its excellent support for autosuggestions and autocomplete. For example, type ls followed by a Tab and you’ll see a list of all commands you can run beginning with ls:

The ls command followed by several rows of commands beginning with "ls"—like lsappinfo and lsm. Each command has a brief description alongside it.

Autosuggestions also work, out of the box, for options and other arguments, like filenames:

A command line reading "ls -F" showing rows of possible completions, each representing an option to the command. One is selected, -F, which appends indicators.

This feature is not only a convenient way of reducing the time it takes to type a command in full, but it also aids discovery. With a simple list of options, for example, it’s much easier to scan and find a useful feature than it is when scrolling through pages of the manual.

Syntax highlighting is another great feature, although it can seem a bit unnecessary until you actually try it. Going far beyond just making things look nice, syntax highlighting can help you understand context and semantics at a glance. Take error reporting, for example; if you typo a command in Fish, it’s immediately obvious:

A command line featuring a typo—"gerp" instead of "grep"—colored in red with the message "fish: Unknown command: gerp."

Fish also comes with built-in web pages for help and configuration. To access either, simply run the help or fish_config command, respectively. Your web browser should open automatically, displaying the relevant page:

The Fish web-based help shows links to sections like Introduction, Frequently asked questions, and The fish language.

Fish’s web interfaces all run locally, so you can consult help or configure the system even if you’re offline.

Fish is approachable and easy for any user, from beginners to experts. As a programmer, you’ll find that its convenient shortcuts will benefit your day-to-day work as much as any other user. But its features can also help with the specific task of programming, too.

Fish is also programmer-friendly

The shell includes features of particular use to coders

A scripting language is core to any shell, and Fish differentiates itself from shells like Bash and Zsh with a language that looks quite different. In general, Fish favours commands over symbolic syntax, so instead of $((i+1)), you’d write math $i + 1.

Fish will help with certain aspects of a migration from Bash by reacting to common mistakes with useful messages:

A command trying to use the $$ variable results in a fish error reading "In fish, please use $fish_pid."

Fish’s default prompt also shows the exit code for the last command, which is a great way of discovering which codes are used, as well as spotting when something’s gone wrong:

The Fish prompt showing an error exit status, 1, in red.

Argument parsing is a very common task for more complex shell scripts, which Bash doesn’t make all too easy. With Fish, you can use the argparse command to define the options that your script supports and automatically populate corresponding variables.

The fish_config command we saw earlier contains some very useful information, like a list of current variable values and key bindings. Of particular relevance is its “functions” page, which allows you to browse defined functions:

The fish web UI showing the content of a function, fish_is_root_user.

You can use this to not only view your own functions, but also browse the many functions that come built into Fish. These include some really useful code, but they’re also great for learning the language.

Another great feature worth checking out is the function command—used to define a function—and the options that it supports. You can use –wraps to declare that your function wraps another command, in which case it will automatically inherit that command’s tab completions. Meanwhile, you can use –description to add brief documentation, which is also used in tab completions.

Why use Fish instead of Bash?

As a programmer, it pays to be ever-curious, so based on that alone, it’s worth checking out the default shell from the currently in-vogue Linux distro. But Fish offers many useful features that will make your programming life more enjoyable and enable you to write programs with greater ease.



Source link

Leave a Reply

Subscribe to Our Newsletter

Get our latest articles delivered straight to your inbox. No spam, we promise.

Recent Reviews


The Samsung Keyboard supports glide typing, voice dictation, multiple languages, and deep customization through Good Lock. On paper, it’s a very capable and perfectly functional keyboard. However, it’s only when I started using it that I realized great features don’t necessarily translate to a great user experience. Here’s every problem I faced with the Samsung Keyboard, and why I’m permanently sticking with Gboard as my main Android keyboard.

I have been using Gboard and the Samsung Keyboard on a recently bought Galaxy S24, which I got at a massive discount.

Google’s voice typing doesn’t cut me off mid-sentence

Fewer corrections, fewer cutoffs, faster dictation

I might be a professional writer, but I hate typing—whether it’s on a physical keyboard or a virtual one. I type slower than I think, which I suspect is true for most people. That becomes a problem when I have multiple ideas in my head and need to get them down fast. It’s happened far too often: I start typing one idea and forget the other. Since jacking my brain into a computer isn’t an option (yet), I’ve been leaning more and more on voice typing as the fastest way to capture my thoughts.

Now, both Samsung Keyboard and Gboard support voice typing, but I’ve noticed that Gboard with Google’s voice engine is just better at transcription accuracy. It picks up on accents flawlessly and manages to output the right words. In my experience, it also seems to have a more up-to-date dictionary. When I mention a proper noun—something recently trending like a video game or a movie name—Samsung’s voice typing fails to catch it, but Google nails it.

That said, you can choose Google as your preferred voice typing engine inside Samsung Keyboard, but it’s a buggy experience. I’ve noticed that the transcription gets cut off while I’m in the middle of talking—even when I haven’t taken a long pause. This can be a real problem when I’m transcribing hands-free.

Gboard offers a more accurate glide typing experience

Google accurately maps my swipe gestures to the right words

Voice typing isn’t always possible, especially when you’re in a crowded place and want to be respectful (or secretive). At times like these, I settle for glide (or swipe) typing. It’s generally much faster than tapping on the keyboard—provided the prediction engine maps your gestures to the right word. If it doesn’t, you have to delete that word, draw that gesture again, or worse—type it out manually.

Now, both Samsung Keyboard and Gboard support glide typing, but I’ve noticed Gboard is far more accurate. That said, when I researched this online, I found a 50-50 divide—some people say Gboard is more accurate, others say Samsung is. I do have a theory on why this happens.

Before my Galaxy S24, I used a Pixel 6a, before that a Xiaomi, and before that a Nokia 6.1 Plus. All of my past smartphones came with Gboard by default. I believe Gboard learned my typing patterns over time—what word correlates to what gesture, which corrections I accept, and which ones I reject. After a decade of building up that prediction model, Gboard knows what I mean when my thumb traces a particular shape. Samsung Keyboard, on the other hand, is starting from zero on this Galaxy S24—leading to all the prediction errors. At least that’s my working theory.

There’s also the argument for muscle memory. While glide typing, you need to hit all the correct keycaps for the prediction engine to work. If you’re even off by a slight amount, the prediction model might think you meant to hit “S” instead of “W.” Now, because of my years of typing on Gboard, it’s likely that my muscle memory is optimized for its specific layout and has trouble adapting to Samsung’s.

Swiping vs typing.


Is Swiping Really Faster Than Typing on a Phone Keyboard?

Which typing method reigns supreme?

I mix three languages in one message, and Gboard just gets it

Predictive multilingual typing doesn’t get any better than this

I’m trilingual—I speak English, Hindi, and Bengali. When I’m messaging my friends and family, we’re basically code-mixing—jumping between languages in the same sentence using the Latin alphabet. Now, my friends and I have noticed that Gboard handles code-mixing much more seamlessly than Samsung Keyboard.

If you just have the English dictionary enabled, neither keyboard can guess that you’re trying to transliterate a different language into English. It’ll always try to autocorrect everything, which breaks the flow. The only way to fix this is by downloading a transliteration dictionary like Hinglish (Hindi + English) or Bangla (Latin). Both Samsung Keyboard and Gboard support these dictionaries, but the problem with Samsung Keyboard is that it can only use one dictionary at a time.

Let’s say I’m writing something in Latinized Bangla and suddenly drop a Hindi phrase. Samsung Keyboard will attempt to autocorrect those Hindi words. Gboard is more context-aware. Since my Hinglish keyboard is already installed, I don’t have to manually switch to it. Gboard can detect that I’m using a Hindi word even with the English or Bangla keyboard enabled, and it won’t try to autocorrect what I’m writing. This also works flawlessly with glide typing, which is a huge quality-of-life improvement over Samsung Keyboard.

This isn’t just an India-specific thing either. Code-mixing is how billions of people type every day—Spanglish in the US, Taglish in the Philippines, Franglais across parts of Europe and Africa.

Gboard looks good without me spending an hour on it

I don’t have time for manual customization

Samsung Keyboard is hands down the more customizable option, especially if you combine it with the Keys Cafe module inside Good Lock. You get granular control over almost every aspect of the keyboard—key colors, keycaps, gesture animations, and a whole lot more. While for some users, this is heaven, I just find it too overcomplicated and a massive time sink.

I don’t have the patience to sit and adjust every visual detail of my keyboard. Sure, it gets stale after a while, and you’d want to freshen it up, but I don’t want to spend the better part of an hour tweaking a virtual keyboard. This is where Gboard wins (at least for me) by doing less.

Android 16 brings Material 3 Expressive, which automatically themes your system apps using your wallpaper’s color scheme. With Gboard, all you have to do is change the wallpaper, and the keyboard updates to match—no Good Lock, no manual color picking. It’s a cleaner, more seamless way to keep your phone looking good without putting in the extra legwork.


The keyboard you don’t think about is the one that’s working

I didn’t switch to Gboard because Samsung Keyboard was broken. I switched because Gboard made typing feel effortless. If you’re a Samsung user who’s never tried it, it’s a free download and a five-second switch. You might not go back either.

Pixel 7 with the 8vim keyboard.


I Tried the Weirdest Android Keyboards So You Don’t Have To

Can strange layouts and gestures beat the good old-fashioned QWERTY?



Source link