如何在 Linux 中安装 Fish,友好的交互式 Shell

, 的缩写 F友好的 一世交互式 ell,是一个用于类 Unix 系统的装备精良、智能且用户友好的 shell。 Fish 具有许多重要功能,例如自动建议、语法高亮、可搜索历史记录(如 Bash 中的 CTRL+r)、智能搜索功能、出色的 VGA 颜色支持、基于 Web 的配置、手册页完成等等,开箱即用. 只需安装它并立即开始使用它。 无需额外配置,或者您无需安装任何额外的附加组件/插件! 在本教程中,让我们讨论如何在 Linux 中安装和使用 fish shell。

内容

  1. 在 Linux 上安装 Fish Shell
  2. 鱼壳用途
    1. 自动建议
    2. 智能搜索
    3. 语法高亮
    4. 基于网络的配置
    5. 手册页完成
    6. 禁用问候语
    7. 获得帮助
    8. 将 Fish 设置为默认 shell
    9. 帮助我们帮助您:

在 Linux 上安装 Fish Shell

尽管 fish 是非常用户友好且功能丰富的 shell,但它并未包含在大多数 Linux 发行版的默认存储库中。 它仅在少数 Linux 发行版的官方存储库中可用,例如 Arch Linux、Gentoo、NixOS 和 Ubuntu 等。

Arch Linux 及其衍生产品,运行以下命令来安装它。

$ sudo pacman -S fish

美分操作系统 8 运行以下作为

# cd /etc/yum.repos.d/
# wget https://download.opensuse.org/repositories/shells:fish/CentOS_8/shells:fish.repo
# yum install fish

美分操作系统 7 运行以下作为

# cd /etc/yum.repos.d/ 
# wget https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo
# yum install fish

美分操作系统 6 运行以下作为

# cd /etc/yum.repos.d/
# wget https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo
# yum install fish

Debian 10 运行以下命令:

$ echo 'deb https://download.opensuse.org/repositories/shells:/fish/Debian_10/ /' | sudo tee /etc/apt/sources.list.d/shells:fish.list
$ curl -fsSL https://download.opensuse.org/repositories/shells:fish/Debian_10/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/shells_fish.gpg > /dev/null
$ sudo apt update
$ sudo apt install fish

Debian 9 运行以下作为

# echo 'deb https://download.opensuse.org/repositories/shells:/fish/Debian_9.0/ /' > /etc/apt/sources.list.d/shells:fish.list # wget -nv https://download.opensuse.org/repositories/shells:fish/Debian_9.0/Release.key -O Release.key # apt-key add - < Release.key # apt-get update # apt-get install fish

Debian 8 运行以下作为

# echo 'deb https://download.opensuse.org/repositories/shells:/fish/Debian_8.0/ /' > /etc/apt/sources.list.d/shells:fish.list # wget -nv https://download.opensuse.org/repositories/shells:fish/Debian_8.0/Release.key -O Release.key # apt-key add - < Release.key # apt-get update # apt-get install fish

在最新 Fedora 版本,运行:

$ sudo df install fish

您也可以从 openSUSE Build Service 安装 Fish。

Fedora 31 运行以下作为

# dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish/Fedora_31/shells:fish.repo
# dnf install fish

Fedora 30 运行以下作为

# dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish/Fedora_30/shells:fish.repo
# dnf install fish

openSUSE 运行以下作为

# zypper install fish

openSUSE Leap 15.2 运行以下作为

# zypper addrepo https://download.opensuse.org/repositories/shells:fish/openSUSE_Leap_15.2/shells:fish.repo
# zypper refresh
# zypper install fish

RHEL 7 运行以下作为

# cd /etc/yum.repos.d/ # wget https://download.opensuse.org/repositories/shells:fish/RHEL_7/shells:fish.repo # yum install fish

RHEL 6 运行以下作为

# cd /etc/yum.repos.d/ # wget https://download.opensuse.org/repositories/shells:fish/RHEL_6/shells:fish.repo # yum install fish

Ubuntu 及其衍生物:

$ sudo apt-get update
$ sudo apt-get install fish

还有一个可用于 Ubuntu 及其衍生产品的官方 PPA。 添加 PPA 并在 Ubuntu 上安装 Fish,如下所示。

$ sudo apt-add-repository ppa:fish-shell/release-3 $ sudo apt-get update $ sudo apt-get install fish 

鱼壳用途

要从默认 shell 切换到 fish,请执行以下操作:

$ fish Welcome to fish, the friendly interactive shell

您可以在以下位置找到默认的鱼配置 ~/.config/fish/config.fish (如同 .bashrc)。 如果它不存在,只需创建它。

自动建议

当我输入一个命令时,它会自动建议一个浅灰色的命令。 因此,我必须输入 Linux 的前几个字母并按 Tab 键才能完成命令。

鱼自动建议

如果有更多的可能性,它会列出它们。 您可以使用从列表中选择任何命令 上/下 方向键。 选择要运行的命令后,只需按右箭头键并按 ENTER 即可运行它。