LinuxCommandLibrary

fish

Friendly Interactive Shell

TLDR

Start an interactive shell session

$ fish
copy

Start an interactive shell session without loading startup configs
$ fish [[-N|--no-config]]
copy

Execute specific commands
$ fish [[-c|--command]] "[echo 'fish is executed']"
copy

Execute a specific script
$ fish [path/to/script.fish]
copy

Check a specific script for syntax errors
$ fish [[-N|--no-execute]] [path/to/script.fish]
copy

Execute specific commands from stdin
$ [echo "echo 'fish is executed'"] | fish
copy

Start an interactive shell session in private mode, where the shell does not access old history or save new history
$ fish [[-P|--private]]
copy

Define and export an environmental variable that persists across shell restarts (builtin)
$ set [[-U|--universal]] [[-x|--export]] [variable_name] [variable_value]
copy

SYNOPSIS

fish [options] [command [arguments...]]

When invoked without arguments, fish starts an interactive shell session. If a command is provided, fish executes it and exits. The shell can also be started as a login shell using the -l option.

PARAMETERS

-c command_string
    Execute the given command_string and then exit. This is useful for running fish scripts from other shells or within automated tasks.

-d debug_category
    Enable debug messages for specific categories, such as 'parser' or 'exec', helping to troubleshoot shell behavior.

-i
    Force the shell to run in interactive mode, even if stdin is not a TTY.

-l
    Start fish as a login shell, which means it sources login-specific configuration files.

-P, --private
    Start a private session where history and changes to universal variables are not saved upon exit.

-v, --version
    Print the version number of fish and exit.

--debug
    Enable full debug output for fish, providing detailed information about its internal operations.

--help
    Display a brief help message with common command-line options and exit.

DESCRIPTION

fish (Friendly Interactive SHell) is a modern, user-friendly command line shell for Unix-like operating systems. Unlike traditional shells like Bash or Zsh, fish aims to be intuitive and discoverable, providing a rich user experience out-of-the-box without extensive configuration.

Its standout features include powerful autosuggestions based on history and completions, which appear as you type, significantly speeding up command entry. It offers intelligent syntax highlighting, marking valid commands in green and invalid ones in red, along with highlighting arguments for clarity. fish also boasts robust tab completion, understanding common commands and their arguments, even for external tools.

While fish provides a powerful interactive experience, its scripting language is unique and not POSIX compliant, meaning scripts written for Bash or Zsh will not directly run in fish. However, its scripting syntax is designed to be simpler and more consistent, often making complex tasks easier to express. It's an excellent choice for users seeking an enhanced, less cumbersome shell experience.

CAVEATS

fish's scripting language is not POSIX compliant, meaning scripts written for Bash, Zsh, or other traditional shells will not run directly without modification. This can be a significant learning curve for users accustomed to traditional shell scripting and may require rewriting existing scripts. Additionally, while fish provides many built-in commands, some common Unix utilities might behave slightly differently or require alternatives within the fish environment.

KEY FEATURES

Beyond the basic command execution, fish offers:
Autosuggestions: Predicts commands as you type, based on history and completions.
Syntax Highlighting: Provides immediate visual feedback on command validity and arguments.
Web-based Configuration: The fish_config command launches a web interface for easy theme and function management.
Universal Variables: Allows variables to be set once and persist across all fish sessions and even after restarts.

CONFIGURATION

fish's configuration is primarily managed through the file ~/.config/fish/config.fish. Unlike Bash or Zsh, which might have multiple configuration files, fish centralizes most user-specific settings here. Functions, key bindings, and variable definitions are typically placed in this file or sourced from other files within the ~/.config/fish/functions/ directory.

HISTORY

fish was created by Axel Liljencrantz and first released in 2005. Its development was driven by a desire for a more user-friendly and intuitive command-line experience, addressing common frustrations with traditional shells. From its inception, fish prioritized interactive features like autosuggestions, syntax highlighting, and sensible defaults, aiming to reduce the cognitive load for users. Over the years, it has gained a dedicated following due to its 'out-of-the-box' usability and powerful features, evolving into a mature and robust shell while maintaining its core philosophy of user-friendliness.

SEE ALSO

bash(1), zsh(1), sh(1), dash(1)

Copied to clipboard