UbuntuUbuntu Based

How To Install Fish Shell on Ubuntu 24.04 LTS

Install Fish Shell on Ubuntu 24.04

The Fish Shell, officially known as the “Friendly Interactive Shell,” has revolutionized the command-line experience for Linux users worldwide. Unlike traditional shells like Bash, Fish offers intelligent features that work seamlessly out of the box, making terminal interactions more intuitive and productive. This comprehensive guide covers everything needed to install and configure Fish Shell on Ubuntu 24.04 LTS systems.

Modern developers and system administrators increasingly choose Fish Shell for its superior autosuggestions, syntax highlighting, and user-friendly interface. The shell’s intelligent tab completions and real-time command validation significantly reduce typing errors and improve workflow efficiency. Whether transitioning from Bash or exploring alternative shells for the first time, Fish provides an enhanced terminal experience that adapts to user patterns and preferences.

Understanding Fish Shell

What Makes Fish Shell Special

Fish Shell distinguishes itself through its philosophy of providing a smart, user-friendly command-line interface without requiring extensive configuration. The shell incorporates advanced features that traditionally required manual setup in other shells, delivering immediate productivity benefits upon installation.

The intelligent autosuggestion system represents one of Fish’s most compelling features. As users type commands, Fish analyzes command history and available executables to suggest completions in real-time. These suggestions appear in subtle gray text, allowing users to accept them with the right arrow key or continue typing to refine the input.

Syntax highlighting provides immediate visual feedback about command validity. Valid commands appear in distinct colors, while invalid or misspelled commands display in red, helping users identify errors before execution. File paths and arguments receive different color treatments, creating a more intuitive visual command structure.

The tab completion system extends beyond basic filename completion. Fish understands command-specific options and arguments, providing contextually relevant suggestions. For example, typing git followed by a tab reveals available Git subcommands, while ls -- shows available options for the ls command.

Fish vs. Other Shells Comparison

Comparing Fish to Bash reveals fundamental philosophical differences. Bash prioritizes POSIX compliance and script compatibility, making it suitable for system administration and scripting environments. Fish emphasizes user experience and interactive usability, sometimes at the expense of strict POSIX compatibility.

Fish vs Zsh comparisons highlight different approaches to shell enhancement. Zsh requires framework installations like Oh My Zsh to achieve similar functionality to Fish’s built-in features. While Zsh offers greater customization potential, Fish provides superior out-of-the-box experience with minimal configuration requirements.

Memory usage and performance characteristics favor Fish in interactive scenarios. The shell’s efficient implementation ensures responsive autosuggestions and syntax highlighting without significant resource overhead. However, users should consider POSIX compliance requirements when choosing Fish for scripting or automated environments.

Prerequisites and System Requirements

Ubuntu 24.04 LTS provides excellent compatibility with Fish Shell installations. Users need administrative privileges through sudo access and a functional terminal emulator. The system should have active internet connectivity for package downloads and repository access.

Before proceeding with installation, identify the current default shell using the echo $SHELL command. This information proves valuable for potential rollback scenarios or troubleshooting configuration conflicts. Additionally, consider backing up existing shell configurations, particularly .bashrc or .zshrc files, to preserve customizations.

Network connectivity requirements include access to Ubuntu’s official repositories or the Fish Shell PPA. Firewall configurations should permit HTTPS connections to package servers. Systems behind corporate proxies may require additional configuration for package manager access.

Installation Methods Overview

Three primary installation approaches accommodate different user requirements and system configurations. The APT package manager method offers stability and automatic security updates through Ubuntu’s official repositories. The official PPA installation provides access to newer Fish versions with latest features and improvements. Source compilation delivers cutting-edge functionality and custom compilation options for advanced users.

Each method presents distinct advantages and limitations. APT installations integrate seamlessly with Ubuntu’s package management system but may include slightly older Fish versions. PPA installations balance currency with stability while maintaining package management benefits. Source compilation offers maximum flexibility but requires additional time and technical expertise.

Method 1: Installing via APT Package Manager (Recommended)

Step-by-Step APT Installation

The APT package manager provides the most straightforward Fish Shell installation method for Ubuntu 24.04 LTS systems. Begin by updating the package repository cache to ensure access to the latest package information:

sudo apt update

This command refreshes the local package database with current repository information. The update process typically completes within seconds, depending on network connectivity and repository responsiveness.

Install Fish Shell using the standard APT installation command:

sudo apt install fish

The package manager automatically resolves dependencies and installs Fish along with required components. Installation progress appears in the terminal, showing download progress and configuration steps. The process typically requires several megabytes of downloads and completes within minutes.

Verify the installation by checking the Fish version:

fish --version

Ubuntu 24.04 LTS repositories typically include Fish Shell version 3.6 or newer. The version command confirms successful installation and displays the specific Fish build information.

Advantages and Limitations

APT installations provide several key benefits for production environments. Automatic security updates ensure Fish remains current with security patches through Ubuntu’s standard update mechanisms. The installation integrates fully with the system’s package management, enabling easy removal or upgrade through standard APT commands.

Package management integration simplifies maintenance tasks. Users can remove Fish using sudo apt remove fish or upgrade through sudo apt upgrade commands. This integration maintains system consistency and follows Ubuntu’s package management best practices.

The primary limitation involves version currency. Ubuntu’s repositories prioritize stability over latest features, potentially including Fish versions that are several months behind the current release. Users requiring cutting-edge features should consider PPA or source installation methods.

Method 2: Installing via Official PPA (Latest Version)

Adding Fish Shell PPA

The Fish Shell team maintains an official Personal Package Archive (PPA) providing access to newer versions than Ubuntu’s standard repositories. Add the PPA to your system’s repository list:

sudo apt-add-repository ppa:fish-shell/release-3

This command registers the Fish Shell PPA with your package manager. The PPA focuses on the Fish 3.x release series, providing stable but current versions. For users interested in Fish 4.x features, alternative PPAs may become available as the newer series stabilizes.

Update the package cache after adding the PPA:

sudo apt update

The update process now includes the newly added PPA repository, downloading package information for Fish Shell versions not available in standard Ubuntu repositories.

PPA Installation Process

Install Fish Shell from the PPA using the standard APT command:

sudo apt install fish

The package manager automatically selects the newer PPA version over the standard repository version. Installation proceeds similarly to the standard APT method but delivers a more current Fish release.

Verify the installation and note the version difference:

fish --version

PPA installations typically provide Fish versions released within weeks or months of the official release, compared to the potentially older versions in Ubuntu’s standard repositories.

PPA Management

Managing PPA installations requires understanding additional maintenance considerations. The PPA provides automatic updates through the standard sudo apt upgrade process, maintaining currency with Fish development.

Remove the PPA if needed using the following command:

sudo apt-add-repository --remove ppa:fish-shell/release-3

This action removes the PPA from your repository list but doesn’t automatically downgrade or remove Fish Shell. Users can then reinstall from standard repositories if desired.

Monitor PPA activity and announcements through the Fish Shell community channels. PPAs occasionally experience temporary issues or maintenance periods that may affect update availability.

Method 3: Building from Source Code

Prerequisites for Source Installation

Source compilation requires development tools and libraries not included in standard Ubuntu installations. Install the essential build environment:

sudo apt install build-essential cmake libncurses5-dev libpcre2-dev gettext

These packages provide the compiler toolchain, build system, and libraries required for Fish compilation. The installation adds approximately 200MB of development tools to your system.

Additional dependencies may be required based on specific Fish features or system configurations. Consult the Fish documentation for comprehensive dependency lists if compilation errors occur.

Source Compilation Process

Download the Fish Shell source code from the official GitHub repository:

wget https://github.com/fish-shell/fish-shell/releases/download/4.1.0/fish-4.1.0-linux-x86_64.tar.xz
tar -xf fish-4.1.0-linux-x86_64.tar.xz
cd fish-4.1.0-linux-x86_64

Replace the version number with the latest release available at the time of installation. The Fish GitHub releases page provides current version information and download links.

Configure the build system using CMake:

mkdir build
cd build
cmake ..

The configuration process analyzes your system and prepares the build environment. CMake output indicates successful configuration or identifies missing dependencies requiring resolution.

Compile Fish Shell using the make command:

make
sudo make install

Compilation time varies based on system performance, typically requiring several minutes on modern hardware. The installation places Fish in /usr/local/bin/fish by default.

When to Choose Source Installation

Source compilation benefits users requiring absolute latest features or specific customization options. Development environments often benefit from source installations to access experimental features or contribute to Fish development.

Custom compilation options enable optimization for specific hardware or use cases. Advanced users can modify compilation flags or enable experimental features not available in package distributions.

Consider source installation maintenance requirements. Updates require manual recompilation rather than package manager automation. This approach suits users comfortable with manual software management and willing to invest additional time in maintenance tasks.

Post-Installation Verification

Test Fish Shell functionality by launching it directly:

fish

The Fish prompt appears with distinctive styling, typically showing the current directory and user information. The interface demonstrates syntax highlighting and autosuggestion capabilities immediately upon startup.

Install Fish Shell on Ubuntu 24.04

Execute basic commands to verify functionality:

ls
pwd
echo "Hello Fish"

Commands should display syntax highlighting with valid commands appearing in distinct colors. The autosuggestion system may propose completions based on command history or available executables.

Exit Fish and return to your previous shell:

exit

Confirm Fish installation location:

which fish

The command output shows Fish’s installation path, typically /usr/bin/fish for package installations or /usr/local/bin/fish for source compilations.

Making Fish Your Default Shell

Understanding Default Shell Change

Changing the default shell affects user login behavior and terminal emulator defaults. The process involves adding Fish to the system’s approved shell list and updating user account settings.

Add Fish to the /etc/shells file if not already present:

echo $(which fish) | sudo tee -a /etc/shells

This command ensures the system recognizes Fish as a legitimate shell option. Some installations automatically handle this step, but manual verification prevents configuration issues.

Alternative Configuration Methods

Change your user account’s default shell using the chsh command:

chsh -s $(which fish)

The command prompts for your user password and updates the default shell setting. Changes take effect after logging out and back in, or restarting the system.

Alternative approaches include configuring terminal emulators directly. Most modern terminal applications allow specifying custom shell commands in their preferences, enabling Fish usage without system-wide changes.

Post-Change Verification and Troubleshooting

Log out and log back in to activate the default shell change. New terminal sessions should automatically launch Fish instead of Bash. The prompt appearance and behavior confirm successful configuration.

Some desktop environments require system restarts for shell changes to take full effect. If Fish doesn’t launch automatically after logout/login, restart the system and test again.

Revert to Bash if issues arise:

chsh -s /usr/bin/bash

This command restores Bash as the default shell, providing a recovery mechanism for problematic configurations.

Essential Fish Shell Configuration

Configuration File Structure

Fish stores user configurations in ~/.config/fish/config.fish. Create the directory structure if it doesn’t exist:

mkdir -p ~/.config/fish
touch ~/.config/fish/config.fish

The configuration file uses Fish’s native syntax rather than Bash-compatible commands. This approach enables Fish-specific features while potentially requiring syntax translation for existing shell configurations.

Basic Customization Options

Set environment variables using Fish’s set command:

set -x EDITOR vim
set -x PATH $PATH ~/bin

The -x flag exports variables, making them available to child processes. Fish’s variable system provides more sophisticated scoping options than traditional shells.

Create command abbreviations for frequently used commands:

abbr -a ll 'ls -la'
abbr -a gs 'git status'
abbr -a gc 'git commit'

Abbreviations expand automatically when typed, providing efficient shortcuts while maintaining command visibility in history.

Define custom functions for complex operations:

function mkcd
    mkdir -p $argv[1]
    cd $argv[1]
end

Functions provide more powerful capabilities than aliases, supporting parameters and complex logic while maintaining Fish’s readable syntax.

Theme and Appearance Configuration

Launch Fish’s web-based configuration interface:

fish_config

This command opens a browser-based configuration tool enabling theme selection, color customization, and prompt modification. The interface provides real-time previews of configuration changes.

Customize prompt appearance through the web interface or by defining custom prompt functions. Fish supports sophisticated prompt customization while maintaining performance and responsiveness.

Essential Configuration Examples

Configure common development environment variables:

set -x GOPATH ~/go
set -x NODE_PATH ~/.npm-global/lib/node_modules
set -x PYTHONPATH ~/python-projects

Set up useful abbreviations for development workflows:

abbr -a gp 'git push'
abbr -a gl 'git log --oneline'
abbr -a gd 'git diff'
abbr -a dc 'docker-compose'
abbr -a k 'kubectl'

These configurations enhance productivity by reducing typing while maintaining command clarity and history usefulness.

Key Features and How to Use Them

Syntax Highlighting in Action

Fish’s syntax highlighting system provides immediate visual feedback about command validity. Valid commands appear in the default text color, while invalid or misspelled commands display in red. This real-time validation helps prevent common typing errors before command execution.

File and directory paths receive special highlighting treatment. Existing paths appear underlined, while non-existent paths lack underlining. This visual indication helps users identify path errors without executing commands.

Command options and arguments display in different colors, creating visual command structure. Users can customize highlighting colors through the web configuration interface or by setting specific Fish variables.

Autosuggestions Feature

The autosuggestion system analyzes command history and available executables to propose completions. Suggestions appear in gray text as users type, allowing acceptance with the right arrow key or Tab completion.

Partial suggestion acceptance uses Ctrl+F to accept only the next word from a suggestion. This feature enables efficient navigation through long commands or file paths without accepting entire suggestions.

The system learns from user patterns, prioritizing frequently used commands and recently accessed files. This adaptive behavior improves suggestion relevance over time, enhancing productivity for regular tasks.

Tab Completions

Fish’s tab completion system extends beyond basic filename completion. Command-specific completions understand individual program options and arguments, providing contextually relevant suggestions.

For example, Git commands receive specialized completions for subcommands, branch names, and file paths. Package managers like APT provide completion for available packages and installed software.

Custom completions can be defined for third-party tools or personal scripts. The Fish completion system uses simple syntax enabling users to extend functionality for their specific workflows.

Interactive Features

Fish includes built-in help accessible through the help command or by pressing Alt+H after typing a command. This integration provides immediate access to documentation without leaving the terminal.

The history search feature uses Ctrl+R to search through command history interactively. Users can type partial commands to filter history, making it easy to locate and reuse previous commands.

Command-line editing benefits from Fish’s enhanced key bindings. Vi mode supporters can enable Vi-style editing, while Emacs users enjoy familiar key combinations with Fish-specific enhancements.

Troubleshooting Common Issues

Default Shell Not Changing

Terminal emulators may override system shell settings with their own configurations. Check terminal preferences to ensure automatic shell detection or specify Fish explicitly in terminal settings.

Verify Fish appears in /etc/shells:

cat /etc/shells

Missing entries require manual addition using administrative privileges. Some systems require explicit shell registration before allowing default shell changes.

Path issues can prevent proper shell launching. Confirm Fish installation location matches the path specified in shell change commands. Package installations typically use /usr/bin/fish, while source installations use /usr/local/bin/fish.

Desktop Environment Problems

Some desktop environments experience compatibility issues when Fish becomes the default shell. Login scripts expecting Bash syntax may fail, causing desktop startup problems.

Create a Bash wrapper script for desktop compatibility:

sudo nano /usr/local/bin/fish-wrapper

Add the following content:

#!/bin/bash
exec /usr/bin/fish "$@"

Make the script executable and use it as the default shell:

sudo chmod +x /usr/local/bin/fish-wrapper
chsh -s /usr/local/bin/fish-wrapper

This approach provides Fish functionality while maintaining Bash compatibility for system scripts.

Script Compatibility Issues

Fish’s non-POSIX syntax creates compatibility issues with Bash scripts. Identify problematic scripts and modify their shebang lines to explicitly specify Bash:

#!/bin/bash

Alternatively, execute Bash scripts directly through the Bash interpreter:

bash script.sh

Environment variable differences between Fish and Bash may cause script failures. Test critical scripts in Fish environments before making permanent shell changes.

PATH and Environment Variables

Fish uses different syntax for environment variable configuration. Convert Bash PATH modifications to Fish syntax:

# Bash syntax
export PATH="$PATH:~/bin"

# Fish syntax
set -x PATH $PATH ~/bin

Universal variables provide Fish-specific variable persistence:

set -U PATH $PATH ~/bin

Universal variables persist across Fish sessions without requiring configuration file modifications.

Performance and Compatibility Considerations

Fish Shell demonstrates excellent performance characteristics for interactive use. Memory usage remains modest compared to heavily customized Zsh installations, while startup time competes favorably with Bash on modern systems.

Server environments may prefer Bash for script compatibility and minimal resource usage. Fish excels in development workstations and interactive terminals where user experience takes priority over strict POSIX compliance.

SSH compatibility requires consideration for remote system access. Many remote systems lack Fish installations, making Bash knowledge essential for system administration tasks. Maintain Bash proficiency alongside Fish usage for comprehensive shell capabilities.

Script portability limitations affect automation and configuration management. Organizations using shell scripts for deployment or configuration should evaluate Fish compatibility carefully before widespread adoption.

Advanced Topics and Extensions

Oh My Fish Framework

Oh My Fish provides package management and theme systems for Fish Shell. Install the framework using:

curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish

The framework enables plugin installation and theme management through simple commands. Popular plugins include Git integration, Node.js tools, and enhanced prompt themes.

Explore available packages:

omf list
omf install bobthefish
omf theme bobthefish

Modern Tool Integration

Fish integrates excellently with modern command-line tools. Starship provides enhanced prompt functionality:

curl -sS https://starship.rs/install.sh | sh
echo 'starship init fish | source' >> ~/.config/fish/config.fish

Zoxide enhances directory navigation with intelligent jumping:

curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
echo 'zoxide init fish | source' >> ~/.config/fish/config.fish

These tools complement Fish’s capabilities while maintaining performance and usability standards.

Security and Best Practices

Keep Fish Shell updated through your chosen installation method. APT installations receive security updates automatically, while PPA and source installations require manual attention to security announcements.

Configuration file security follows standard Unix practices. Protect configuration files from unauthorized access:

chmod 600 ~/.config/fish/config.fish

Backup configurations regularly, especially before major updates or system changes. Version control systems like Git provide excellent configuration management for power users.

Multi-user environments benefit from system-wide Fish configurations in /etc/fish/config.fish. Administrative privileges are required for system-wide changes, but the approach ensures consistent experiences across user accounts.

Congratulations! You have successfully installed Fish Shell. Thanks for using this tutorial to install the latest version of the Fish Shell on Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Fish Shell website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button