Friendly interactive shell

Friendly interactive shell

infobox software
name = fish



caption = The friendly interactive shell
author = Axel Liljencrantz
developer = Axel Liljencrantz
released =
latest release version = 1.23.0
latest release date = 13 January 2008
operating system = Unix-like
genre = Unix shell
license = GNU General Public License
website = http://fishshell.org/

fish is a Unix shell. Its name is an acronym for "friendly interactive shell". fish 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 under the terms of the GNU General Public License, fish is free software.

Highlights

fish features a user-friendly and powerful tab completion, including descriptions of every completion, tab-completion of strings with wildcards, 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.

Syntax

The fish syntax is slightly different from other shell script 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.

# Variable assignment, set the variable 'foo' to the value 'bar'. # Don't use the = operator, since it is inherently whitespace sensitive. # Also, the set command can easily be extended to work with arrays, scoping, etc. > set foo bar > echo $foo bar # Command substitution, assign the output of the command 'pwd' into the variable 'wd'. # Don't use `` since they can't be nested and look too much like like ' '. # Don't use $() since $ is only used for variable expansion in fish. > set wd (pwd) > echo $wd ~ # Array variables. 'A' becomes an array with the values 3, 5, 7, 9, 12 > set A 3 5 7 9 12 > echo $A [(seq 3)] 3 5 7 # Array slicing. 'B' becomes the first and second element of 'A' > set B $A [1 2] > echo $B 3 5 # Erase the third and fifth elements of 'A' > set -e A [$B] ; echo $A 3 5 9 # for-loop, convert jpegs to pngs > for i in *.jpg; convert $i (basename $i .jpg).png; end # while-loop, read lines /etc/passwd and output the fifth # colon-separated field from the file. This should be # the user description. )> cat /etc/passwd|while read line; set arr (echo $line|tr : ); echo $arr [5] ; end

One important difference between fish and other shells is the lack of subshells. Many tasks like pipelines, 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, so 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 instantly 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 highlighting with extensive error checking.
* Support for the X clipboard.
* Smart terminal handling based on terminfo.
* Searchable command history.

See also

* Comparison of computer shells

External links

* [http://fishshell.org Project home page]
* [http://sourceforge.net/projects/fish/ fish] on SourceForge.net
* [http://lwn.net/Articles/136232/ An introductory article about fish]
* [http://arstechnica.com/articles/columns/linux/linux-20051218.ars/2 Fish: the friendly interactive shell] (an in-depth look at fish) at Ars Technica


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Friendly interactive shell — Pour les articles homonymes, voir Fish. Friendly Interactive Shell …   Wikipédia en Français

  • Friendly Interactive Shell — Pour les articles homonymes, voir Fish. Friendly Interactive Shell …   Wikipédia en Français

  • 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… …   Wikipedia

  • Unix shell — A Unix shell, is a command line shell that provides the traditional user interface for the Unix operating system and for Unix like systems. Users direct the operation of the computer by entering command input as text for a command line… …   Wikipedia

  • Bourne-Again-Shell — Die Unix Shell oder kurz Shell (en. Hülle, Schale) bezeichnet die traditionelle Benutzerschnittstelle unter Unix oder unixoiden Betriebssystemen. Der Benutzer kann in einer Eingabezeile Kommandos eintippen, die der Computer dann sogleich ausführt …   Deutsch Wikipedia

  • Bourne-Shell — Die Unix Shell oder kurz Shell (en. Hülle, Schale) bezeichnet die traditionelle Benutzerschnittstelle unter Unix oder unixoiden Betriebssystemen. Der Benutzer kann in einer Eingabezeile Kommandos eintippen, die der Computer dann sogleich ausführt …   Deutsch Wikipedia

  • Perl-Shell — Die Unix Shell oder kurz Shell (en. Hülle, Schale) bezeichnet die traditionelle Benutzerschnittstelle unter Unix oder unixoiden Betriebssystemen. Der Benutzer kann in einer Eingabezeile Kommandos eintippen, die der Computer dann sogleich ausführt …   Deutsch Wikipedia

  • Unix-Shell — Die Unix Shell oder kurz Shell (en. Hülle, Schale) bezeichnet die traditionelle Benutzerschnittstelle unter Unix oder unixoiden Computer Betriebssystemen. Der Benutzer kann in einer Eingabezeile Kommandos eintippen, die der Computer dann sogleich …   Deutsch Wikipedia

  • Thompson shell — Original author(s) Ken Thompson Initial release 1971 Operating system Unix License Unix shell The Thompson shell was the first Unix shel …   Wikipedia

  • PWB shell — The PWB shell (also known as the Mashey shell) was an early Unix shell.[1] Distributed with some versions of Programmer s Workbench UNIX circa 1975 1977, it was a modified (and generally constrained to be upward compatible) version of the… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”