Fish (Unix shell): Difference between revisions

Content deleted Content added
m Adjective addition for description
document that fish was written in C++ in the past
 
(22 intermediate revisions by 15 users not shown)
Line 7:
{{Infobox software
| name = Fish
| logo = Fish-shell-logo-ascii icon.svgpng
| screenshot = Fish shell 34.30.10 screenshot.pngwebp
| screenshot size = 300px
| caption = Version 34.30.10 of fish
| 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>
| released = {{release date and age|df=yes|2005|02|13|df=yes}}
| latest release version = {{wikidata|property|reference|edit|P348}}
| latest release date = {{Start date and age|{{wikidata|qualifier|P348|P577}}|df=yes}}
| programming language = [[Rust (programming language)|Rust]] since v4.0<ref>{{cite web |title=fish-shell 4.0b1, now in Rust |url=https://fishshell.com/blog/fish-4b/ |website=fishshell.com |access-date=18 December 2024}}</ref>, [[C++]] up to v3.7.1<ref>{{cite web |url=https://fishshell.com/docs/current/relnotes.html#fish-4-0-0-released-february-27-2025 |title=fish 4.0.0 (released February 27, 2025) |website=fishshell.com |access-date=2025-08-16}}</ref>
| programming language = [[Rust (programming language)|Rust]]
| operating system = [[Unix-like]]
| genre = [[Unix shell]]
Line 22:
| website = {{URL|http://fishshell.com}}
}}
'''Fish''' ('''friendly interactive shell'''; stylized in lowercase) is a [[Unix shell|Unix-like shell]] with a focus on interactivity and usability. Fish is designed to be feature-rich by default, rather than highly configurable.,<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 itand does not adhere to [[POSIX]] shell standards, at the discretion of itsby maintainersdesign.<ref>{{cite web|url=https://fishshell.com/docs/current/design.html|title=Fish docs: design|access-date=2021-04-09}}</ref>
 
==HighlightsFeatures==
Fish hasdisplays [[incremental search|searchincremental as you typesuggestions]] automaticas suggestionsthe user types, based on command history and the current directory. This functions likesimilarly to [[Bash (Unix shell)|Bash]]'s {{keypress|Ctrl|R}} history search, but is always on, giving the user continuous feedback while writingtyping the command linecommands. UsersFish canalso selectincludes suggestions with the arrow keys, or as in Bash, press {{keypress|tab}} for a tab completion instead.feature-rich [[command-line completion|Tab-tab completion]], iswith feature-richsupport and hasfor expanding file paths (with [[wildcard character|wildcard]]s and [[Bash (Unix shell)#Brace expansion|brace expansion]]{{Broken anchor|date=2025-07-31|bot=User:Cewbot/log/20201008/configuration|target_link=Bash (Unix shell)#Brace expansion|reason=Anchor "Bash (Unix shell)#Brace expansion" links to a specific web page: "Brace expansion". The anchor (Brace expansion) [[Special:Diff/1303454031|has been deleted]].|diff_id=1303454031}}), [[Environment variable|environment variables]], and many command -specific completions. Command-specific completions, including options with descriptions, which can be to some extent be generated from the commands' [[man page|man pages]], but custom completions can also be included with software or written by users of the shell.<ref>{{Cite web |title=Writing your own completions |url=https://fishshell.com/docs/current/completions.html |url-status=live |archive-url=https://web.archive.org/web/20240831075627/https://fishshell.com/docs/current/completions.html |archive-date=2024-08-31 |website=fish shell}}</ref>
 
The creator of fishFish preferred to makeadd new features as commands rather than syntax. This makesmade features more [[Discoverability|discoverable]], as the built-in termsfeatures allow ofsearching commands with options and help texts. [[Subroutine|Functions]] can also carry ainclude human readable descriptiondescriptions. 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==
Line 93:
 
=== No implicit subshell ===
Some language constructs, like [[pipeline (software)|pipelines]], [[subroutine|functions]] and [[control flow#Loops|loops]], have been implemented using so called [[Child process|subshells]] in other [[shell (computing)|shell]] languages. Subshells are child programs that run a few commands forin theorder shellto andperform a task, then exit back to the parent shell. 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 forkscreates offsubshells so-calledfor subshellslanguage features; all [[Shell_builtin|builtins]] arehappen alwayswithin fullythe functionalparent shell.
<syntaxhighlight lang="fish">
# This will not work in many other shells, since the 'read' builtin
Line 147:
 
==Other features==
* Advanced tab completion (with support for writing custom completions).
* [[Syntax highlighting]] with extensive error checking.
* Support for the [[X Window System|X]] [[Clipboard (software)|clipboard]].
* Smart [[Computer terminal|terminal]] handling based on [[terminfo]].
* Searchable [[command history]].
* Web-based configuration ([https://fishshell.com/docs/current/cmds/fish_config.html fish_config]).
 
==Bash/fish translation table==
{| class="wikitable"
|-
! style="width: 15%" | Feature !! style="width: 25%" | Bash syntax !! style="width: 45%" | fish syntax !! style="width: 15%" |Comment
|-
| variable expansion:<br />with word splitting and [[glob (programming)|glob]] interpretation ||
Line 335:
* [[Comparison of command shells]]
* [[Unix]]
* [[Unix shell]]
 
==References==
{{Reflist|colwidth=50em35em|refs=
 
<ref name="bash_pitfalls">{{cite web|title=Bash Pitfalls|url=http://mywiki.wooledge.org/BashPitfalls|quote=This page shows common errors that Bash programmers make. (...) You will save yourself from many of these pitfalls if you simply always use quotes and never use word splitting for any reason! Word splitting is a broken legacy misfeature inherited from the Bourne shell that's stuck on by default if you don't quote expansions. The vast majority of pitfalls are in some way related to unquoted expansions, and the ensuing word splitting and globbing that result.|access-date=2016-07-10}}</ref>
 
}}
Line 348 ⟶ 347:
*[https://github.com/fish-shell/fish-shell fish] on [[GitHub]] (active)
*[https://web.archive.org/web/20110726104750/http://gitorious.org/fish-shell/ fish] on [[Gitorious]] (obsolete)
*[httphttps://sourceforge.net/projects/fish/ fish] on [[SourceForge]] (obsolete)
*[https://lists.sourceforge.net/lists/listinfo/fish-users Fish-users] – general discussion list for fish users
*[https://github.com/fish-shell/fish-shell/wiki/Shell-Translation-Dictionary Shell Translation Dictionary] - another Bash/Fish translation table
Line 358 ⟶ 357:
[[Category:Scripting languages]]
[[Category:Unix shells]]
[[Category:Free software programmed in Rust]]