2019-03-14 20:52:25 +00:00
.. highlight :: fish-docs-samples
2019-03-31 09:32:40 +00:00
.. _intro:
2018-12-16 00:23:36 +00:00
2018-12-16 02:45:16 +00:00
Introduction
2021-03-03 19:30:35 +00:00
***** ***** **
2018-12-16 00:23:36 +00:00
2020-12-26 21:45:48 +00:00
This is the documentation for **fish** , the **f** \ riendly **i** \ nteractive **sh** \ ell.
2019-02-24 23:46:10 +00:00
2020-12-26 21:45:48 +00:00
A shell is a program that helps you operate your computer by starting other programs. fish offers a command-line interface focused on usability and interactive use.
2019-12-09 19:44:57 +00:00
2021-01-27 15:58:12 +00:00
Unlike other shells, fish does not follow the POSIX standard, but still uses roughly the same model.
2019-02-24 23:46:10 +00:00
2019-09-11 04:16:19 +00:00
Some of the special features of fish are:
2019-02-24 23:46:10 +00:00
2021-03-03 19:30:35 +00:00
- **Extensive UI** : :ref: `Syntax highlighting <color>` , :ref: `autosuggestions` , :ref: `tab completion <tab-completion>` and selection lists that can be navigated and filtered.
2019-02-24 23:46:10 +00:00
2019-09-11 04:16:19 +00:00
- **No configuration needed** : fish is designed to be ready to use immediately, without requiring extensive configuration.
2019-02-24 23:46:10 +00:00
2021-02-05 18:50:05 +00:00
- **Easy scripting** : New :ref: `functions <syntax-function>` can be added on the fly. The syntax is easy to learn and use.
2019-02-24 23:46:10 +00:00
2021-03-03 19:30:35 +00:00
This page explains how to install and set up fish and where to get more information.
2021-10-23 15:13:36 +00:00
Where to go?
============
2021-05-18 20:51:28 +00:00
2021-03-03 19:30:35 +00:00
If this is your first time using fish, see the :ref: `tutorial <tutorial>` .
2019-02-24 23:46:10 +00:00
2021-01-22 15:23:09 +00:00
If you are already familiar with other shells like bash and want to see the scripting differences, see :ref: `Fish For Bash Users <fish_for_bash_users>` .
2021-03-03 19:30:35 +00:00
For a comprehensive overview of fish's scripting language, see :ref: `The Fish Language <language>` .
For information on using fish interactively, see :ref: `Interactive use <interactive>` .
2021-10-23 15:13:36 +00:00
If you need to install fish first, read on, the rest of this document will tell you how to get, install and configure fish.
2019-02-24 23:46:10 +00:00
Installation and Start
======================
2021-01-31 10:57:51 +00:00
This section describes how to install, uninstall, start, and exit the fish shell. It also explains how to make fish the default shell.
2019-12-10 17:35:25 +00:00
2019-02-24 23:46:10 +00:00
Installation
------------
2019-09-11 04:18:27 +00:00
Up-to-date instructions for installing the latest version of fish are on the `fish homepage <https://fishshell.com/> `_ .
2019-02-24 23:46:10 +00:00
2020-12-26 21:45:48 +00:00
To install the development version of fish, see the instructions on the `project's GitHub page <https://github.com/fish-shell/fish-shell> `_ .
2019-02-24 23:46:10 +00:00
Starting and Exiting
--------------------
2019-09-11 04:18:27 +00:00
Once fish has been installed, open a terminal. If fish is not the default shell:
2019-02-24 23:46:10 +00:00
2020-12-26 21:45:48 +00:00
- Type `` fish `` to start a fish shell::
2019-02-24 23:46:10 +00:00
> fish
2020-12-26 21:45:48 +00:00
- Type `` exit `` to exit a fish shell::
2019-02-24 23:46:10 +00:00
> exit
Executing Bash
--------------
2020-12-26 21:45:48 +00:00
If fish is your default shell and you want to copy commands from the internet that are written in bash (the default shell on most systems), you can proceed in one of the following two ways:
2019-02-24 23:46:10 +00:00
2020-12-26 21:45:48 +00:00
- Use the `` bash `` command with the `` -c `` switch to read from a string::
2019-02-24 23:46:10 +00:00
2020-07-15 06:21:43 +00:00
> bash -c 'some bash command'
2019-02-24 23:46:10 +00:00
2020-12-26 21:45:48 +00:00
- Use `` bash `` without a switch to open a bash shell you can use and `` exit `` afterward::
2020-07-15 06:21:43 +00:00
> bash
$ some bash command
$ exit
> _
2019-02-24 23:46:10 +00:00
2019-12-10 17:35:25 +00:00
Default Shell
-------------
2020-12-26 21:45:48 +00:00
To make fish your default shell:
2020-07-15 05:58:57 +00:00
2021-01-27 17:25:46 +00:00
- Add the line `` /usr/local/bin/fish `` to `` /etc/shells `` .
2020-12-26 21:45:48 +00:00
- Change your default shell with `` chsh -s /usr/local/bin/fish `` .
2019-12-10 17:35:25 +00:00
2020-07-15 05:58:57 +00:00
For detailed instructions see :ref: `Switching to fish <switching-to-fish>` .
2019-12-10 17:35:25 +00:00
Uninstalling
------------
For uninstalling fish: see :ref: `FAQ: Uninstalling fish <faq-uninstalling>` .
2019-12-10 17:29:57 +00:00
Shebang Line
------------
2020-12-26 21:45:48 +00:00
Because shell scripts are written in many different languages, they need to carry information about which interpreter should be used to execute them. For this, they are expected to have a first line, the shebang line, which names the interpreter executable.
2019-12-10 17:29:57 +00:00
2021-11-04 20:26:54 +00:00
A script written in `` bash `` would need a first line like this:
::
2019-12-10 17:29:57 +00:00
#!/bin/bash
2021-01-27 15:58:12 +00:00
When the shell tells the kernel to execute the file, it will use the interpreter `` /bin/bash `` .
2019-12-10 17:29:57 +00:00
2021-01-27 15:58:12 +00:00
For a script written in another language, just replace `` /bin/bash `` with the interpreter for that language (for example: `` /usr/bin/python `` for a python script, or `` /usr/local/bin/fish `` for a fish script).
2019-12-10 17:29:57 +00:00
2020-12-26 21:45:48 +00:00
This line is only needed when scripts are executed without specifying the interpreter. For functions inside fish or when executing a script with `` fish /path/to/script `` , a shebang is not required (but it doesn't hurt!).
2019-12-10 17:29:57 +00:00
2018-12-16 00:23:36 +00:00
2021-10-23 15:13:36 +00:00
Where to add configuration
==========================
2018-12-16 00:23:36 +00:00
2021-10-23 15:13:36 +00:00
If you have any configuration you want to store, simply write it to a file called `` ~/.config/fish/config.fish `` .
2018-12-16 00:23:36 +00:00
2021-10-23 15:13:36 +00:00
If you want to split it up, you can also use files named something.fish in `` ~/.config/fish/conf.d/ `` . Fish will automatically load these on startup, in order, before config.fish.
2018-12-16 00:23:36 +00:00
2021-10-23 15:13:36 +00:00
These files are read on the startup of every shell, whether it's interactive or a login shell or not. Use `` status --is-interactive `` and `` status --is-login `` to only do things for interactive shells or login shells.
2018-12-16 00:23:36 +00:00
2021-10-23 15:13:36 +00:00
This is a simplified answer for ordinary users, if you are a sysadmin or a developer who wants a program to integrate with fish, see :ref: `configuration` for the full scoop.
2018-12-16 00:23:36 +00:00
Examples:
2021-05-15 16:38:11 +00:00
If you want to add the directory `` ~/linux/bin `` to your PATH variable when using a login shell, add this to your `` ~/.config/fish/config.fish `` file::
2018-12-16 00:23:36 +00:00
2018-12-16 02:45:16 +00:00
if status --is-login
2021-02-01 17:12:24 +00:00
set -gx PATH $PATH ~/linux/bin
2018-12-16 02:45:16 +00:00
end
2018-12-16 00:23:36 +00:00
2021-05-15 16:38:11 +00:00
(alternatively use :ref: `fish_add_path <cmd-fish_add_path>` like `` fish_add_path ~/linux/bin `` , which only adds the path if it isn't included yet)
2021-02-05 19:02:52 +00:00
If you want to run a set of commands when fish exits, use an :ref: `event handler <event>` that is triggered by the exit of the shell::
2018-12-16 00:23:36 +00:00
2018-12-16 02:45:16 +00:00
function on_exit --on-event fish_exit
echo fish is now exiting
end
.. _more-help:
Further help and development
============================
2018-12-16 00:23:36 +00:00
If you have a question not answered by this documentation, there are several avenues for help:
2020-09-18 15:19:44 +00:00
- The `GitHub page <https://github.com/fish-shell/fish-shell/> `_
2018-12-16 00:23:36 +00:00
2020-09-18 15:19:44 +00:00
- The official `Gitter channel <https://gitter.im/fish-shell/fish-shell> `_
2018-12-16 00:23:36 +00:00
2020-09-18 15:19:44 +00:00
- The official mailing list at `fish-users@lists.sourceforge.net <https://lists.sourceforge.net/lists/listinfo/fish-users> `_
2018-12-16 00:23:36 +00:00
2020-09-18 15:19:44 +00:00
If you have an improvement for fish, you can submit it via the GitHub page.
2019-03-29 18:08:25 +00:00
.. _other_pages:
2021-07-14 14:57:22 +00:00
Other help pages
================
.. toctree ::
:maxdepth: 1
self
faq
interactive
language
commands
fish_for_bash_users
tutorial
completions
design
relnotes
license