Puneet Varma (Editor)

Friendly interactive shell

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Original author(s)
  
Axel Liljencrantz

Operating system
  
Unix-like

Friendly interactive shell

Developer(s)
  
ridiculousfish, siteshwar, JanKanis

Initial release
  
13 February 2005; 12 years ago (2005-02-13)

Stable release
  
2.5.0 / 3 February 2017; 40 days ago (2017-02-03)

Repository
  
github.com/fish-shell/fish-shell

The friendly interactive shell (fish) is a Unix shell that attempts to be more interactive and user-friendly than those with a longer history (i.e. most other Unix shells) or those formulated as function-compatible replacements for the aforementioned (i.e. zsh, the Falstad shell). The design goal of fish is to give the user a rich set of powerful features in a way that is easy to discover, remember, and use. fish is considered an "exotic shell", in that its syntax derives from neither the Bourne shell (ksh, bash, zsh) nor the C shell (csh, tcsh). Also unlike previous shells, which disable certain features by default to save system resources, fish enables all features by default.

Contents

Highlights

fish has "search as you type" automatic suggestions based on history and current directory. This is essentially like bash's Ctrl+R history search, but because it is always on instead of being a separate mode, the user gets continuous feedback while writing the command line, and can select suggestions with the arrow keys, or as in bash, press Tab ↹ for a tab completion instead. Tab-completion is feature-rich, expanding file paths (with wildcards and brace expansion), variables, and many command specific completions. Command-specific completions, including options with descriptions, can to some extent be generated from the commands' manpages.

Fish has few syntactic rules, preferring features as commands rather than syntax. This makes features discoverable in terms of commands with options and help texts. Functions can also carry a human readable description. A special help command gives access to all the fish documentation in the user's web browser.

Syntax

The syntax resembles a POSIX compatible shell (such as bash), but deviates in important ways where the creators believe the POSIX shell was badly designed.

No implicit subshell

Some language constructs, like pipelines, functions and loops, have been implemented using so called subshells in other shell languages. Subshells are simply child programs that run a few commands for the shell and then exit. Unfortunately, this implementation detail typically has the side effect that any state changes made in the subshell, such as variable assignments, do not propagate to the main shell, which may surprise the user. Fish never forks off so-called subshells; all builtins are always fully functional.

Variable assignment example

This bash example does not do what it looks like: because the loop body is a subshell, the update to $found is not persistent.

Workaround:

Fish needs no workaround:

Helpful error messages

Error messages in fish are designed to actually tell the user what went wrong and what can be done about it.

Universal variables

Fish has a feature known as universal variables, which allow a user to permanently assign a value to a variable across all the user's running fish shells. The variable value is remembered across logouts and reboots, and updates are immediately propagated to all running shells.

Other features

  • Advanced tab completion.
  • Syntax highlighting with extensive error checking.
  • Support for the X clipboard.
  • Smart terminal handling based on terminfo.
  • Searchable command history.
  • Version 2 adds:

  • Autosuggestions
  • 256 terminal colors
  • Web-based configuration
  • Improved performance (by having more builtins).
  • References

    Friendly interactive shell Wikipedia