Fish (Unix shell): Difference between revisions

Content deleted Content added
m Reverted edits by Chiragrasane (talk) (AV)
m minor changes to grammar and addition of links
Line 11:
| screenshot = Fish shell 3.3.1 screenshot.png
| screenshot size = 300px
| caption = Version 3.3.1 of fish
| caption = The fish shell. Its tagline, "fish - the friendly interactive shell", is displayed at the top.
| author = Axel Liljencrantz
| developer = Fish-shell developers<ref>{{cite web| url = https://github.com/fish-shell?tab=members| title = fish shell team members | publisher = GitHub.com| date = | access-date = 2021-07-28}}</ref>
Line 23:
| website = {{URL|http://fishshell.com}}
}}
'''fish''' (stylized in lowercase) is a [[Unix shell]] with a focus on interactivity and usability. Fish is designed to give the user features by default, rather than by configuration.<ref>{{cite web|url=https://lwn.net/Articles/136232|publisher=[[Linux Weekly News]]|title=Fish - A user-friendly shell|access-date=2010-03-24|date=2005-05-17|author=Liljencrantz, Axel}}</ref> Fish is considered an [[Unix shell#Other shells|exotic shell]] since it does not adhere to [[POSIX]] shell standards, at the discretion of the maintainers.<ref>{{cite web|url=https://fishshell.com/docs/current/design.html|title=Fish docs: design|access-date=2021-04-09}}</ref>
 
==Highlights==
Fish has [[incremental search|search as you type]] [[Comparison of command shells#Automatic suggestions|automatic suggestions]] based on history and current directory. This is essentially like Bash's {{keypress|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 {{keypress|tab}} for a tab completion instead. [[command-line completion|Tab-completion]] is feature-rich and has expanding file paths (with [[wildcard character|wildcard]]s and [[Bash (Unix shell)#Brace expansion|brace expansion]]), variables, and many command specific completions. Command-specific completions, including options with descriptions, can to some extent be generated from the commands' [[man page|man pages]].
Fish has "[[incremental search|search as you type]]" [[Comparison of command shells#Automatic suggestions|automatic suggestions]] based on history and current directory.
This is essentially like Bash's {{keypress|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 {{keypress|tab}} for a tab completion instead. [[command-line completion|Tab-completion]] is feature-rich and has expanding file paths (with [[wildcard character|wildcard]]s and [[Bash (Unix shell)#Brace expansion|brace expansion]]), variables, and many command specific completions. Command-specific completions, including options with descriptions, can to some extent be generated from the commands' [[man page|man pages]].
 
Fish prefers features as commands rather than syntax. This makes features [[Discoverability|discoverable]] in terms of commands with options and help texts. [[Subroutine|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]].<ref>[https://www.linux.com/news/cli-magic-enhancing-shell-fish Linux.com]. CLI Magic: Enhancing the shell with fish. Retrieved 2010-03-24.</ref>
 
==Syntax==
The syntax resembles a [[POSIX]] compatible shell (such as Bash), but deviates in importantmany ways where the creators believe the POSIX shell was badly designed.<ref name=indepthfish>{{cite web|last1=Paul|first1=Ryan|title=An in-depth look at fish: the friendly interactive shell|url=https://arstechnica.com/information-technology/2005/12/linux-20051218/2/|website=[[Ars Technica]]|date=19 December 2005 |access-date=10 March 2015|quote=the Posix syntax has several missing or badly implemented features, including variable scoping, arrays, and functions. For this reason, fish strays from the Posix syntax in several important places.}}</ref>
 
<syntaxhighlight lang="fish">
Line 95 ⟶ 94:
 
=== No implicit subshell ===
Some language constructs, like [[pipeline (software)|pipelines]], [[subroutine|functions]] and [[control flow#Loops|loops]], have been implemented using so called [[Subshell|subshells]] in other [[shell (computing)|shell]] languages. Subshells are child programs that run a few commands for the shell and then exit. 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. Fish never forks off so-called subshells; all [[Shell_builtin|builtins]] are always fully functional.
<syntaxhighlight lang="fish">
# This will not work in many other shells, since the 'read' builtin
Line 336 ⟶ 335:
{{Portal|Free and open-source software}}
* [[Comparison of command shells]]
* [[Unix]]
* [[Unix shell]]
 
==References==