Fish shell, usually written simply as fish (the friendly interactive shell), is a Unix command-line shell designed around interactive usability rather than strict POSIX compatibility. In the Linux shell & terminal environment, it plays the same role as Bash or Zsh: it reads commands, starts programs, manages pipes and redirection, and runs scripts, but it ships with autosuggestions, syntax highlighting and rich tab completion enabled by default.
Fish deliberately breaks with the Bourne shell syntax that Bash, Zsh and KornShell inherit. Its scripting language is smaller and more consistent, which makes it pleasant for daily terminal work but means that existing sh and Bash scripts do not run in fish unchanged. Most administrators therefore use fish as an interactive login shell while keeping system scripts in POSIX sh or Bash.
How fish works as an interactive shell
Fish works as a read-evaluate loop that parses each command line, expands variables and wildcards, and executes builtins, functions or external programs. What distinguishes it is the work done while the user is still typing: the line editor continuously consults command history, completion definitions and the filesystem to give live feedback before the Enter key is pressed.
The autosuggestion engine proposes the rest of a command in muted gray text, based first on history matching the current directory and then on completions and valid paths. Pressing the right arrow or Ctrl+F accepts the suggestion, and Alt+Right accepts a single word. Syntax highlighting colors valid commands differently from unknown ones, so a misspelled program name appears in red before it is run.
Completions come from two sources. Fish includes hand-written completion files for hundreds of tools, and it can also parse manual pages with the fish_update_completions command to generate completions for programs that lack them. Completions show descriptions next to each option, which reduces trips to the documentation.
The table below summarizes the main interactive features that fish enables without any configuration.
| Feature | What it does | How to use it |
|---|---|---|
| Autosuggestions | Proposes the rest of a command from history and paths | Right arrow or Ctrl+F to accept |
| Syntax highlighting | Colors commands, arguments and errors as they are typed | Automatic, themes via fish_config |
| Tab completion | Lists options and arguments with descriptions | Tab, then arrow keys to choose |
| History search | Filters past commands by the typed prefix | Up arrow or Ctrl+R |
| Abbreviations | Expands short tokens into full commands visibly | abbr –add gco git checkout |
| Web configuration | Browser interface for colors, prompts and variables | fish_config |
The fish scripting language
The fish scripting language follows the principle that every construct should be a command with ordinary arguments. Blocks end with the keyword end instead of fi, done or esac, variables are assigned with the set builtin rather than name=value, and command substitution uses parentheses, as in set files (ls).
Fish removes several classic pitfalls of Bourne-style shells. Variables are lists, so a value containing spaces is never split into separate words, and quoting mistakes that break Bash scripts largely disappear. Variable scope is explicit through the flags -l (local), -g (global) and -U (universal), and exported variables are marked with -x.
The following comparison shows how common constructs differ between Bash and fish.
| Task | Bash syntax | Fish syntax |
|---|---|---|
| Set a variable | name=value | set name value |
| Export a variable | export EDITOR=vim | set -gx EDITOR vim |
| Command substitution | $(date) | (date) or $(date) |
| Conditional block | if ...; then ...; fi | if ...; ...; end |
| Loop over items | for f in *; do ...; done | for f in *; ...; end |
| Last exit status | $? | $status |
| Define a function | f() { ...; } | function f; ...; end |
Since fish 3.0, the shell also accepts &&, || and ! alongside its native and, or and not, and version 3.4 added $(...) substitution. These additions narrowed the gap with Bash for one-liners, but fish still does not implement POSIX sh semantics, so heredocs, [[ ]] tests and Bash arrays remain unavailable.
Configuration, functions and universal variables
Fish configuration lives in `~/.config/fish/config.fish`, which fish reads at every start, together with the directories functions/, completions/ and conf.d/. This layout follows the XDG Base Directory convention and replaces the split between .bashrc and .bash_profile that confuses many Bash users.
Functions are autoloaded on demand: a file named functions/gst.fish defines the function gst the first time the command is used, which keeps startup fast even with large configurations. The funced and funcsave commands edit a function interactively and save it to the right file. The prompt itself is just a function called fish_prompt.
Universal variables are a feature unique to fish. A variable set with set -U is stored on disk and shared immediately across all running fish sessions of the same user. Changing a color theme or a PATH entry with fish_add_path in one terminal therefore affects every open terminal without reloading anything.
Fish compared with Bash and Zsh
Fish, Bash and Zsh are all Unix shells, but they target different priorities. Bash is the default on most Linux distributions and the reference for portable scripts, Zsh offers Bash compatibility plus deep customization, and fish trades compatibility for sensible defaults and a cleaner language.
| Property | Fish | Bash | Zsh |
|---|---|---|---|
| POSIX sh compatibility | No | Largely yes | Mostly, in sh mode |
| Autosuggestions by default | Yes | No | Through plugins |
| Syntax highlighting by default | Yes | No | Through plugins |
| Configuration effort | Minimal | Moderate | High for full features |
| Default on Linux distributions | Rarely | Most distributions | Some, also macOS |
| Best suited for | Interactive daily work | System and portable scripts | Customized interactive use |
Many Zsh users rely on frameworks such as Oh My Zsh to obtain features that fish provides natively. The fish equivalent of such a framework, for example a plugin manager, is optional and mostly used for prompts and extra functions rather than for core usability.
Adopting fish safely on Linux
Fish is packaged by all major distributions and is installed with the usual package manager, for example apt install fish or dnf install fish. The safest adoption path is to keep Bash as the system shell for scripts and use fish only as the interactive environment.
The decision table below covers the most common situations.
| Situation | Recommended approach | Reason |
|---|---|---|
| Personal workstation | Set fish as login shell with chsh | Full benefit of interactive features |
| Shared or production server | Start fish manually from Bash | Avoids surprising other administrators |
| System and deployment scripts | Keep a POSIX sh or Bash shebang | Portability and predictable behavior |
| Personal helper scripts | Write in fish with a fish shebang | Cleaner syntax and fewer quoting bugs |
| Tools that print Bash setup lines | Use the tool’s fish mode or a wrapper | Bash export syntax fails in fish |
Before running chsh -s /usr/bin/fish, the path must be listed in `/etc/shells`, otherwise the change is refused. Some administrators prefer to launch fish from the end of .bashrc so that login scripts and environment setup still run in Bash first.
Limitations and common mistakes
The main limitation of fish is its deliberate incompatibility with POSIX sh. Copying a Bash snippet from documentation into a fish prompt often fails with a syntax error, and sourcing Bash files such as a virtual environment activation script does not work unless the tool provides a fish variant.
- Setting fish as root’s login shell can break recovery tools and scripts that assume a POSIX shell.
- Using `export VAR=value` habits works only partially;
set -gxis the reliable form. - Expecting word splitting of unquoted variables leads to wrong results, because fish never splits list elements.
- Overusing universal variables for temporary values clutters every session and persists across reboots.
- Assuming Bash completions apply is incorrect; fish uses its own completion format.
Stripped to the essentials
Fish is a program that lets people type commands to a Linux computer in a text window. Its goal is to be helpful without any setup. As someone types, it guesses the rest of the command from what they used before, much like a phone keyboard suggesting the next word.
It also colors mistakes before they cause trouble and shows short explanations for each option. The trade-off is that fish speaks a slightly different command language from Bash, so older scripts written for Bash usually need to stay in Bash.
Where it is applied
A backend developer on an Ubuntu laptop spends most of the day in the terminal, moving between a dozen project directories and running long docker compose and kubectl commands. After switching the login shell to fish, the developer types the first few letters of a deployment command and accepts the full command from autosuggestions with one keystroke, because fish remembers which commands were used in that specific directory.
Project deployment scripts keep their #!/bin/bash shebang and run unchanged, since fish only replaced the interactive shell. Within a week the developer defines ten abbreviations for frequent Git commands and sets the project tools path once with fish_add_path. The result is fewer typing errors and less time searching history, while every automated script remains portable to the team’s Bash-based build servers.