Content deleted Content added
svg logo |
document that fish was written in C++ in the past |
||
(44 intermediate revisions by 30 users not shown) | |||
Line 2:
{{Multiple issues|
{{More citations needed|date=May 2019}}
{{
{{Missing information|Fish's history|date=March 2022}}
}}
{{Infobox software
| name = Fish
| logo = Fish
| screenshot = Fish shell
| screenshot size = 300px
| caption = Version 4.0.0 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
| latest release version = {{wikidata|property|reference|edit|P348}}
| latest release date =
| 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>
| operating system = [[Unix-like]]
| genre = [[Unix shell]]
Line 23 ⟶ 22:
| website = {{URL|http://fishshell.com}}
}}
'''
==
Fish displays [[incremental search|incremental suggestions]] as the user types, based on command history and the current directory. This functions similarly to [[Bash (Unix shell)|Bash]]'s {{keypress|Ctrl|R}} history search, but is always on, giving the user continuous feedback while typing commands. Fish also includes feature-rich [[command-line completion|tab completion]], with support for 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 command-specific completions. Command-specific completions, including options with descriptions, can be to some extent 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
==Syntax==
The syntax resembles a [[POSIX]] compatible shell (such as Bash), but deviates in
<syntaxhighlight lang="fish">
# Variable assignment
# # #
▲# command easily extends to work with arrays, scoping, etc.
> set foo bar
> echo $foo
bar
# Command substitution
#
#
# Fish doesn't use backticks (``), which can't be nested and may be confused with single quotes (' ').
> set wd (pwd)
> set wd $(pwd) # since version 3.4
Line 70 ⟶ 72:
convert $i (basename $i .jpg).png
end
# fish supports multi-line history and editing.▼
# Semicolons work like newlines:
> for i in *.jpg; convert $i (basename $i .jpg).png; end
▲# fish supports multi-line history and editing.
# while-loop, read lines /etc/passwd and output the fifth
Line 89 ⟶ 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
<syntaxhighlight lang="fish">
# This will not work in many other shells, since the 'read' builtin
Line 120 ⟶ 124:
</syntaxhighlight>
Fish example:
<syntaxhighlight lang="fish">
set found ''
Line 131 ⟶ 135:
==Universal variables==
Fish has a feature known as universal variables, which
<syntaxhighlight lang="fish">
# This will make emacs the default text editor. The '--universal' (or '-U') tells fish to
Line 143 ⟶ 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 186 ⟶ 184:
| edit line in text editor || {{keypress|Ctrl|X}},{{keypress|Ctrl|E}} || {{keypress|Alt|E}} || Upon invocation, moves line input to a text editor
|-
| evaluate line input || {{keypress|Ctrl|Alt|E}} || {{n/a}}<ref>{{cite web|url=https://github.com/fish-shell/fish-shell/issues/751|title=RFC: Add binding to expand/evaluate tokens on commandline|website=[[GitHub]] |date=2013-05-16|access-date=2021-04-09}}</ref> || Evaluates expressions in-place on the line editor
|-
| history completion || {{keypress|Ctrl|R}} || {{Yes|implicit}} ||
Line 311 ⟶ 309:
| array representation in environment variables || <syntaxhighlight lang="bash">PATH="$PATH:$HOME/.local/bin"</syntaxhighlight> || <syntaxhighlight lang="fish">set PATH $PATH $HOME/.local/bin</syntaxhighlight> || fish assumes colon as array delimiter for translating variables to and from the environment. This aligns with many array-like environment variables, like $PATH and $LS_COLORS.
|-
| export and run ||
LANG=C.UTF-8
| <syntaxhighlight lang="fish">env LANG=C.UTF-8 python3</syntaxhighlight>
| <syntaxhighlight lang="bash" inline>env LANG=C.UTF-8 python3</syntaxhighlight> works in any shell, as env is a standalone program.
Line 336 ⟶ 334:
{{Portal|Free and open-source software}}
* [[Comparison of command shells]]
* [[Unix]]
==References==
{{Reflist|colwidth=
<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. (
}}
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)
*[
*[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]]
|