Fish (Unix shell): Difference between revisions

Content deleted Content added
Syswraith (talk | contribs)
Added the full form in the first paragraph, and added a hyperlink to fish_config.
CatInTree (talk | contribs)
Fixed some grammar issues, added a couple links, clarified some info about features, and added a source for info about custom completions
Line 22:
| website = {{URL|http://fishshell.com}}
}}
'''Fish ('''or '''f'''riendly '''i'''nteractive '''sh'''ell- 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 it does not adhere to [[POSIX]] shell standards, at the discretion of its maintainers.<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|search asincremental 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]]), [[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 Fish preferred to makeadd new features as commands rather than syntax. This made 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|subs hellssubshells]] 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