每个Linux管理员都可能听说过shell这个词。你知道什么是贝壳吗?你知道Linux中shell的作用是什么吗?Linux中有多少个shell可用?shell是在用户和内核之间提供接口的程序。内核是Linux操作系统的心脏,管理着用户和操作系统之间的一切。启动终端时,所有用户都可以使用Shell。终端启动后,用户可以运行任何可用的命令。当shell完成执行命令时,您将在终端窗口中获??得输出。Bash(BourneAgainShell的缩写)是当今大多数Linux发行版上运行的默认shell,它非常流行并且功能丰富。但今天我们将讨论鱼壳。什么是鱼壳?Fish是一个友好的交互式shell,它是一个功能齐全、智能且用户友好的Linux命令行shell,具有大多数shell所没有的一些方便的功能。这些功能包括自动完成建议、SaneScripting、手册页完成、基于Web的配置器和GloriousVGAColor。你对它感到好奇并想测试一下吗?如果是,请按照下面的安装步骤继续安装。如何在Linux中安装FishShell?它非常易于安装,并且在大多数发行版中不可用,少数除外。但是,可以使用以下fish存储库轻松安装它。对于基于ArchLinux的系统,使用Pacman命令安装fishshell。$sudopacman-Sfish对于Ubuntu16.04/18.04系统,请使用APT-GET命令或APT命令安装fishshell。$sudoapt-add-repositoryppa:fish-shell/release-3$sudoapt-getupdate$sudoapt-getinstallfish对于Fedora系统,使用DNF命令安装fishshell。对于Fedora29系统:$sudodnfconfig-manager--add-repohttps://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/shells:fish:release:3.repo$sudodnfinstallfish对于Fedora28系统:$sudodnfconfig-manager--add-repohttps://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_28/shells:fish:release:3.repo$sudodnfinstallfish对于Debian系统,请使用APT-GET命令或APT命令安装fishshell。对于Debian9系统:$sudowget-nvhttps://download.opensuse.org/repositories/shells:fish:release:3/Debian_9.0/Release.key-ORelease.key$sudoapt-keyadd-/etc/apt/sources.list.d/shells:fish:release:3.list$sudoapt-getupdate$sudoapt-getinstallfish对于Debian8系统:$sudowget-nvhttps://download.opensuse.org/repositories/shells:fish:release:3/Debian_8.0/Release.key-ORelease.key$sudoapt-keyadd-/etc/apt/sources.list.d/shells:fish:release:3.list$sudoapt-getupdate$sudoapt-getinstallfishforRHEL/CentOS对于系统,使用YUM命令安装fishshell。对于RHEL7系统:$sudoyum-config-manager--add-repohttps://download.opensuse.org/repositories/shells:/fish:/release:/3/RHEL_7/shells:fish:release:3。repo$sudoyuminstallfish对于RHEL6系统:$sudoyum-config-manager--add-repohttps://download.opensuse.org/repositories/shells:/fish:/release:/3/RedHat_RHEL-6/shells:fish:release:3.repo$sudoyuminstallfish对于CentOS7系统:$sudoyum-config-manager--add-repohttps://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo$sudoyuminstallfish对于CentOS6系统:$sudoyum-config-manager--add-repohttps://download.opensuse。org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo$sudoyuminstallfish对于openSUSELeap系统,使用Zypper命令安装fishshell。$sudozypperaddrepohttps://download.opensuse.org/repositories/shells:/fish:/release:/3/openSUSE_Leap_42.3/shells:fish:release:3.repo$suodzypperrefresh$sudozypperinstallfish如何使用鱼壳?成功安装fishshell后。只需在您的终端上输入fish,它就会自动从默认的bashshell切换到fishshell。$fish自动补全建议当您在fishshell中键入任何命令时,它会在键入几个字母后自动建议一个浅灰色的命令。一旦你得到一个建议并按右光标键(LCTT译注:原文左转,错误)来完成它而不是键入完整的命令。您可以在键入几个字母后立即按向上光标键来检索命令的先前历史记录。它类似于bashshell的CTRL+r选项。TabCompletion如果您想查看给定命令是否有其他可能性,只需在键入几个字母后按Tab键即可。再次按Tab键查看完整列表。Syntaxhighlightingfish做的是语法高亮,在终端输入任何命令都能看到。无效的命令是红色的。同样,有效命令以不同颜色显示。此外,fish会在您键入有效的文件路径时为其添加下划线,如果路径无效则不会为其添加下划线。基于web的配置器fishshell中有一个很酷的功能,它允许我们通过web浏览器设置颜色、提示、功能、变量、历史和键绑定。在终端运行以下命令,启动web配置界面。只需按Ctrl+c即可退出。$fish_configWeb配置从“file:///home/daygeek/.cache/fish/web_config-86ZF5P.html”开始。按回车键停止。qt5ct:使用qt5ct插件^CShuttingdown。手册页补全其他shell支持可编程补全,但只有fish可以通过解析已安装的手册页自动生成它们。要使用此功能,请运行以下命令:$fish_update_completions解析手册页并将完成写入/home/daygeek/.local/share/fish/generated_completions/3466/3466:zramctl.8.gz如何将Fish设置为默认shell如果你想测试一下fishshell,你可以将fishshell设置为默认shell,而不是每次都切换它。为此,首先使用以下命令获取FishShell的位置。$whereisfishfish:/usr/bin/fish/etc/fish/usr/share/fish/usr/share/man/man1/fish.1.gz通过运行以下命令将默认shell更改为fishshell。$chsh-s/usr/bin/fish提示:只需确认FishShell已添加到/etc/shells目录。如果没有,则运行以下命令来附加它。$echo/usr/bin/鱼|sudotee-a/etc/shells如果你想在测试完成后返回到bashshell,请使用以下命令。临时返回:$bash***返回:$chsh-s/bin/bash