← Back to fish-shell/fish-shell

How to Deploy & Use fish-shell/fish-shell

Fish Shell Deployment and Usage Guide

Prerequisites

  • Rust (for building from source)
  • CMake (required for building dependencies)
  • pkg-config (for locating libraries)
  • Development headers for ncurses, libiconv, and libintl (on Linux)
  • A C compiler (gcc or clang)

Installation

From Source (Recommended)

# Clone the repository
git clone https://github.com/fish-shell/fish-shell.git
cd fish-shell

# Create build directory and configure
mkdir build
cd build
cmake ..

# Build and install
make
sudo make install

# Add fish to available shells (if not already present)
which fish | sudo tee -a /etc/shells

# Change default shell to fish
chsh -s $(which fish)

Package Manager Installation

macOS (Homebrew):

brew install fish

Ubuntu/Debian:

sudo apt update
sudo apt install fish

Fedora:

sudo dnf install fish

Configuration

Fish automatically creates a configuration directory at ~/.config/fish/ on first launch.

Key Configuration Files

  • ~/.config/fish/config.fish - Main configuration file
  • ~/.config/fish/functions/ - Custom functions directory
  • ~/.config/fish/conf.d/ - Configuration snippets loaded in alphabetical order

Environment Variables

Fish uses its own environment variable system. Key variables include:

  • fish_bind_mode - Current key binding mode (default: "default")
  • fish_color_* - Color variables for syntax highlighting
  • fish_greeting - Custom greeting message

Universal Variables

Fish supports universal variables that sync across sessions:

# Set a universal variable
set -U EDITOR nvim

# Remove a universal variable
set -e EDITOR

Build & Run

Development Build

# From the build directory
cmake -DCMAKE_BUILD_TYPE=Debug ..
make

# Run fish from build directory
src/fish

Production Build

# From the build directory
cmake -DCMAKE_BUILD_TYPE=Release ..
make

# Install to system
sudo make install

Running Fish

# Start fish shell
fish

# Run a single command with fish
fish -c "echo hello"

# Start fish without loading configuration
fish --no-config

Deployment

Local Development

Fish is designed as a local shell replacement. For development purposes:

  1. Install via package manager or build from source
  2. Set as default shell using chsh
  3. Customize configuration in ~/.config/fish/

Container Deployment

For containerized environments, use a Dockerfile:

FROM ubuntu:latest

RUN apt-get update && apt-get install -y fish

# Set fish as default shell
RUN echo "fish" >> /etc/shells
SHELL ["/usr/bin/fish", "-c"]

# Copy configuration if needed
COPY config.fish /root/.config/fish/

CI/CD Integration

Add fish to your CI pipeline:

# GitHub Actions example
- name: Install fish
  run: sudo apt-get install -y fish

- name: Test fish configuration
  run: fish -c "type -q fish && echo 'Fish installed successfully'"

Troubleshooting

Common Issues

1. "fish: command not found" after installation

# Add fish to your PATH
echo 'set -x PATH /usr/local/bin $PATH' >> ~/.config/fish/config.fish

# Or check installation path
which fish

2. Syntax highlighting not working

# Check if fish_color_variables are set
set -U fish_color_normal
set -U fish_color_command
set -U fish_color_quote

# Reset color scheme
fish_config prompt choose

3. Slow startup

# Check for slow functions
fish -c "functions --all | head -20"

# Profile startup time
fish -c "time fish"

4. Unicode/wide character display issues

# Check widechar support
fish -c "printf '%s\n' (set -l c (printf '\\U1F600'); printf '%s' $c; printf ' %d' (string length $c))"

# Update terminal settings if needed
echo 'set -g fish_term24bit 1' >> ~/.config/fish/config.fish

Debug Mode

Enable debug logging:

# Start fish with debug output
fish --debug

# Check specific components
fish --debug=input
fish --debug=env

Configuration Validation

# Check configuration syntax
fish -n ~/.config/fish/config.fish

# List all functions
fish -c "functions"

# Show universal variables
fish -c "set -U"

Performance Issues

# Clear universal variable cache
rm -f ~/.config/fish/fishd.*

# Check for conflicting plugins
fish -c "fisher list"