怎么在Linux中安装、配置和使用Fish Shell

发布时间:2021-08-26 15:35:53 作者:chen
来源:亿速云 阅读:157

这篇文章主要讲解了“怎么在Linux中安装、配置和使用Fish Shell”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么在Linux中安装、配置和使用Fish Shell”吧!

什么是 Fish Shell?

Fish 是友好的交互式 shell ,是一个功能齐全,智能且对用户友好的 Linux 命令行 shell ,它带有一些在大多数 shell 中都不具备的方便功能。

这些功能包括自动补全建议、Sane Scripting、手册页补全、基于 Web 的配置器和 Glorious VGA Color 。你对它感到好奇并想测试它吗?如果是这样,请按照以下安装步骤继续安装。

如何在 Linux 中安装 Fish Shell ?

它的安装非常简单,除了少数几个发行版外,它在大多数发行版中都没有。但是,可以使用以下 fish 仓库 轻松安装。

对于基于 Arch Linux 的系统, 使用 Pacman 命令 来安装 fish shell。

$ sudo pacman -S fish

对于 Ubuntu 16.04/18.04 系统来说,请使用 APT-GET 命令 或者 APT 命令 安装 fish shell。

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

对于 Fedora 系统来说,请使用 DNF 命令 安装 fish shell。

对于 Fedora 29 系统来说:

$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/shells:fish:release:3.repo$ sudo dnf install fish

对于 Fedora 28 系统来说:

$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_28/shells:fish:release:3.repo$ sudo dnf install fish

对于 Debian 系统来说,请使用 APT-GET 命令 或者 APT 命令 安装 fish shell。

对于 Debian 9 系统来说:

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

对于 Debian 8 系统来说:

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

对于 RHEL/CentOS 系统来说,请使用 YUM 命令 安装 fish shell。

对于 RHEL 7 系统来说:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/RHEL_7/shells:fish:release:3.repo$ sudo yum install fish

对于 RHEL 6 系统来说:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/RedHat_RHEL-6/shells:fish:release:3.repo$ sudo yum install fish

对于 CentOS 7 系统来说:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo$ sudo yum install fish

对于 CentOS 6 系统来说:

$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo$ sudo yum install fish

对于 openSUSE Leap 系统来说,请使用 Zypper 命令 安装 fish shell。

$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:/fish:/release:/3/openSUSE_Leap_42.3/shells:fish:release:3.repo$ suod zypper refresh$ sudo zypper install fish

如何使用 Fish Shell ?

一旦你成功安装了 fish shell 。只需在你的终端上输入 fish ,它将自动从默认的 bash shell 切换到 fish shell 。

$ fish

 怎么在Linux中安装、配置和使用Fish Shell

自动补全建议

当你在 fish shell 中键入任何命令时,它会在输入几个字母后以浅灰色自动建议一个命令。

怎么在Linux中安装、配置和使用Fish Shell

一旦你得到一个建议然后按下向右光标键(LCTT 译注:原文是左,错的)就能完成它而不是输入完整的命令。

怎么在Linux中安装、配置和使用Fish Shell

你可以在键入几个字母后立即按下向上光标键检索该命令以前的历史记录。它类似于 bash shell 的 CTRL+r 选项。

Tab 补全

如果你想查看给定命令是否还有其他可能性,那么在键入几个字母后,只需按一下 Tab 键即可。

怎么在Linux中安装、配置和使用Fish Shell

再次按 Tab 键可查看完整列表。

怎么在Linux中安装、配置和使用Fish Shell

语法高亮

fish 会进行语法高亮显示,你可以在终端中键入任何命令时看到。无效的命令被着色为 RED color

怎么在Linux中安装、配置和使用Fish Shell

同样的,有效的命令以不同的颜色显示。此外,当你键入有效的文件路径时,fish 会在其下面加下划线,如果路径无效,则不会显示下划线。

怎么在Linux中安装、配置和使用Fish Shell

基于 Web 的配置器

fish shell 中有一个很酷的功能,它允许我们通过网络浏览器设置颜色、提示符、功能、变量、历史和键绑定。

在终端上运行以下命令以启动 Web 配置界面。只需按下 Ctrl+c 即可退出。

$ fish_configWeb config started at 'file:///home/daygeek/.cache/fish/web_config-86ZF5P.html'. Hit enter to stop.qt5ct: using qt5ct plugin^CShutting down.

 怎么在Linux中安装、配置和使用Fish Shell

手册页补全

其他 shell 支持可编程的补全,但只有 fish 可以通过解析已安装的手册页自动生成它们。

要使用该功能,请运行以下命令:

$ fish_update_completionsParsing man pages and writing completions to /home/daygeek/.local/share/fish/generated_completions/ 3466 / 3466 : zramctl.8.gz

如何将 Fish 设置为默认 shell

如果你想测试 fish shell 一段时间,你可以将 fish shell 设置为默认 shell,而不用每次都切换它。

要这样做,首先使用以下命令获取 Fish Shell 的位置。

$ whereis fishfish: /usr/bin/fish /etc/fish /usr/share/fish /usr/share/man/man1/fish.1.gz

通过运行以下命令将默认 shell 更改为 fish shell 。

$ chsh -s /usr/bin/fish

 怎么在Linux中安装、配置和使用Fish Shell

提示:只需验证 Fish Shell 是否已添加到 /etc/shells 目录中。如果不是,则运行以下命令以附加它。

$ echo /usr/bin/fish | sudo tee -a /etc/shells

完成测试后,如果要返回 bash shell ,请使用以下命令。

暂时返回:

$ bash

***返回:

$ chsh -s /bin/bash

感谢各位的阅读,以上就是“怎么在Linux中安装、配置和使用Fish Shell”的内容了,经过本文的学习后,相信大家对怎么在Linux中安装、配置和使用Fish Shell这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

推荐阅读:
  1. 在Linux中安装Oracle(安装总结)
  2. oracle 在 Linux下安装环境配置

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux shell

上一篇:Yii2如何实现log输出到file及database

下一篇:如何使用Shell脚本实现每隔100行插入一条记录且记录第一列包含行号其他列不变

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》