Friendly interactive shell
Encyclopedia
The friendly interactive shell (fish) is a Unix shell
that focuses on interactive use, discoverability, and user friendliness. 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.
Released in 2005 under the terms of the GNU General Public License
, fish is free software
according to the Free Software Foundation
.
, including descriptions of every completion, tab-completion of strings with wildcard
s, and many command specific completions. It also features an extensive and discoverable help system. A special help command gives access to all the fish documentation in the user's web browser
.
languages. These changes were made to make the language more powerful as well as to make the language small and easy to learn. One obvious difference between fish and other command-line interpreters like bash is that the contents of a variable is not subject to token separation, meaning that there is rarely a need to enclose variable dereferences within quotes.
One important difference between fish and other shells
is the lack of subshells. Many tasks like pipeline
s, functions
and loops are implemented using so called subshells in other languages. Subshells are simply child programs that run a few commands for the shell and then exit. Unfortunately, changes made inside a subshell do not have any effect in the main shell, meaning that actions such as variable assignments and the use of many builtin functions do not work as expected. Fish never forks off so-called subshells; all builtins are always fully functional.
# This will not work in most other shells, since the 'read' builtin
# will run in its own subshell. fish and zsh work as expected.
> cat *.txt | read line
> foo=bar
fish: Unknown command “foo=bar”. Did you mean “set VARIABLE VALUE”?
For information on setting variable values, see the help section on
the set command by typing “help set”.
> echo ${foo}bar
fish: Did you mean {$VARIABLE}? The '$' character begins a variable
name. A bracket, which directly followed a '$', is not allowed as a
part of a variable name, and variable names may not be zero characters
long. To learn more about variable expansion in fish, type “help
expand-variable”.
> echo $(pwd)
fish: Did you mean (COMMAND)? In fish, the '$' character is only used
for accessing variables. To learn more about command substitution in
fish, type “help expand-command-substitution”.
# This will make emacs the default text editor. The '-U' tells fish to
# make this a universal variable.
> set -U EDITOR emacs
# This command will make the current working directory part of the fish
# prompt turn blue on all running fish instances.
> set -U fish_color_cwd blue
Unix shell
A Unix shell is a command-line interpreter or shell that provides a traditional user interface for the Unix operating system and for Unix-like systems...
that focuses on interactive use, discoverability, and user friendliness. 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.
Released in 2005 under the terms of the GNU General Public License
GNU General Public License
The GNU General Public License is the most widely used free software license, originally written by Richard Stallman for the GNU Project....
, fish is free software
Free software
Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...
according to the Free Software Foundation
Free Software Foundation
The Free Software Foundation is a non-profit corporation founded by Richard Stallman on 4 October 1985 to support the free software movement, a copyleft-based movement which aims to promote the universal freedom to create, distribute and modify computer software...
.
Highlights
fish features a user-friendly and powerful tab-completionCommand line completion
Command line completion is a common feature of command line interpreters, in which the program automatically fills in partially typed commands....
, including descriptions of every completion, tab-completion of strings with wildcard
Wildcard character
-Telecommunication:In telecommunications, a wildcard character is a character that may be substituted for any of a defined subset of all possible characters....
s, and many command specific completions. It also features an extensive and discoverable help system. A special help command gives access to all the fish documentation in the user's web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...
.
Syntax
The fish syntax is slightly different from other shell scriptShell script
A shell script is a script written for the shell, or command line interpreter, of an operating system. It is often considered a simple domain-specific programming language...
languages. These changes were made to make the language more powerful as well as to make the language small and easy to learn. One obvious difference between fish and other command-line interpreters like bash is that the contents of a variable is not subject to token separation, meaning that there is rarely a need to enclose variable dereferences within quotes.
One important difference between fish and other shells
Shell (computing)
A shell is a piece of software that provides an interface for users of an operating system which provides access to the services of a kernel. However, the term is also applied very loosely to applications and may include any software that is "built around" a particular component, such as web...
is the lack of subshells. Many tasks like pipeline
Pipeline (software)
In software engineering, a pipeline consists of a chain of processing elements , arranged so that the output of each element is the input of the next. Usually some amount of buffering is provided between consecutive elements...
s, functions
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....
and loops are implemented using so called subshells in other languages. Subshells are simply child programs that run a few commands for the shell and then exit. Unfortunately, changes made inside a subshell do not have any effect in the main shell, meaning that actions such as variable assignments and the use of many builtin functions do not work as expected. Fish never forks off so-called subshells; all builtins are always fully functional.
# This will not work in most other shells, since the 'read' builtin
# will run in its own subshell. fish and zsh work as expected.
> cat *.txt | read line
Helpful error messages
Error messages in fish are designed to actually tell the user what went wrong and what can be done about it.> foo=bar
fish: Unknown command “foo=bar”. Did you mean “set VARIABLE VALUE”?
For information on setting variable values, see the help section on
the set command by typing “help set”.
> echo ${foo}bar
fish: Did you mean {$VARIABLE}? The '$' character begins a variable
name. A bracket, which directly followed a '$', is not allowed as a
part of a variable name, and variable names may not be zero characters
long. To learn more about variable expansion in fish, type “help
expand-variable”.
> echo $(pwd)
fish: Did you mean (COMMAND)? In fish, the '$' character is only used
for accessing variables. To learn more about command substitution in
fish, type “help expand-command-substitution”.
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.# This will make emacs the default text editor. The '-U' tells fish to
# make this a universal variable.
> set -U EDITOR emacs
# This command will make the current working directory part of the fish
# prompt turn blue on all running fish instances.
> set -U fish_color_cwd blue
Other features
- Advanced tab completion.
- Syntax highlightingSyntax highlightingSyntax highlighting is a feature of some text editors that display text—especially source code—in different colors and fonts according to the category of terms. This feature eases writing in a structured language such as a programming language or a markup language as both structures and...
with extensive error checking. - Support for the XX Window SystemThe X window system is a computer software system and network protocol that provides a basis for graphical user interfaces and rich input device capability for networked computers...
clipboardClipboard (software)The clipboard is a software facility that can be used for short-term data storage and/or data transfer between documents or applications, via copy and paste operations...
. - Smart terminalComputer terminalA computer terminal is an electronic or electromechanical hardware device that is used for entering data into, and displaying data from, a computer or a computing system...
handling based on terminfoTerminfoTerminfo is a library and database that enables programs to use display terminals in a device-independent manner. This library has its origins in the UNIX System III operating system....
. - Searchable command historyCommand HistoryCommand history is a feature in many operating system shells, computer algebra programs, and other software that allows the user to recall, edit and rerun previous commands....
.
External links
- Project home page
- Community version project page
- fish on SourceForge.netSourceForge.netSourceForge is a web-based source code repository. It acts as a centralized location for software developers to control and manage open source software development. The website runs a version of SourceForge Enterprise Edition, forked from the last open-source version available...
- An introductory article about fish
- Fish: the friendly interactive shell (an in-depth look at fish) at Ars TechnicaArs TechnicaArs Technica is a technology news and information website created by Ken Fisher and Jon Stokes in 1998. It publishes news, reviews and guides on issues such as computer hardware and software, science, technology policy, and video games. Ars Technica is known for its features, long articles that go...