偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

如何在Linux上安裝友好的交互式shell:Fish

系統(tǒng) Linux
Fish,友好的交互式 shell 的縮寫,它是一個(gè)適于裝備于類 Unix 系統(tǒng)的智能而用戶友好的 shell。Fish 有著很多重要的功能,比如自動(dòng)建議、語法高亮、可搜索的歷史記錄、智能搜索功能、極好的 VGA 顏色支持、基于 web 的設(shè)置方式、完善的手冊(cè)頁和許多開箱即用的功能。在這篇教程中,我們討論如何在 Linux 中安裝和使用 fish shell。

 [[212770]]

Fish,友好的交互式 shell 的縮寫,它是一個(gè)適于裝備于類 Unix 系統(tǒng)的智能而用戶友好的 shell。Fish 有著很多重要的功能,比如自動(dòng)建議、語法高亮、可搜索的歷史記錄(像在 bash 中 CTRL+r)、智能搜索功能、極好的 VGA 顏色支持、基于 web 的設(shè)置方式、完善的手冊(cè)頁和許多開箱即用的功能。盡管安裝并立即使用它吧。無需更多其他配置,你也不需要安裝任何額外的附加組件/插件!

在這篇教程中,我們討論如何在 Linux 中安裝和使用 fish shell。

安裝 Fish

盡管 fish 是一個(gè)非常用戶友好的并且功能豐富的 shell,但并沒有包括在大多數(shù) Linux 發(fā)行版的默認(rèn)倉庫中。它只能在少數(shù) Linux 發(fā)行版中的官方倉庫中找到,如 Arch Linux,Gentoo,NixOS,和 Ubuntu 等。然而,安裝 fish 并不難。

在 Arch Linux 和它的衍生版上,運(yùn)行以下命令來安裝它。

  1. sudo pacman -S fish 

在 CentOS 7 上以 root 運(yùn)行以下命令:   

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

在 CentOS 6 上以 root 運(yùn)行以下命令:

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

在 Debian 9 上以 root 運(yùn)行以下命令:   

  1. wget -nv https://download.opensuse.org/repositories/shells:fish:release:2/Debian_9.0/Release.key -O Release.key 
  2.  
  3. apt-key add - < Release.key 
  4.  
  5. echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_9.0/ /' > /etc/apt/sources.list.d/fish.list 
  6.  
  7. apt-get update 
  8.  
  9. apt-get install fish 

在 Debian 8 上以 root 運(yùn)行以下命令:

  1. wget -nv https://download.opensuse.org/repositories/shells:fish:release:2/Debian_8.0/Release.key -O Release.key 
  2.  
  3. apt-key add - < Release.key 
  4.  
  5. echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_8.0/ /' > /etc/apt/sources.list.d/fish.list 
  6.  
  7. apt-get update 
  8.  
  9. apt-get install fish 

在 Fedora 26 上以 root 運(yùn)行以下命令:

  1. dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/Fedora_26/shells:fish:release:2.repo 
  2.  
  3. dnf install fish 

在 Fedora 25 上以 root 運(yùn)行以下命令:

  1. dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/Fedora_25/shells:fish:release:2.repo 
  2.  
  3. dnf install fish 

在 Fedora 24 上以 root 運(yùn)行以下命令:

  1. dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/Fedora_24/shells:fish:release:2.repo 
  2.  
  3. dnf install fish 

在 Fedora 23 上以 root 運(yùn)行以下命令:

  1. dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/Fedora_23/shells:fish:release:2.repo 
  2.  
  3. dnf install fish 

在 openSUSE 上以 root 運(yùn)行以下命令:

  1. zypper install fish 

在 RHEL 7 上以 root 運(yùn)行以下命令:

  1. cd /etc/yum.repos.d/ 
  2.  
  3. wget https://download.opensuse.org/repositories/shells:fish:release:2/RHEL_7/shells:fish:release:2.repo 
  4.  
  5. yum install fish 

在 RHEL-6 上以 root 運(yùn)行以下命令:

  1. cd /etc/yum.repos.d/ 
  2.  
  3. wget https://download.opensuse.org/repositories/shells:fish:release:2/RedHat_RHEL-6/shells:fish:release:2.repo 
  4.  
  5. yum install fish 

在 Ubuntu 和它的衍生版上:

  1. sudo apt-get update 
  2.  
  3. sudo apt-get install fish 

就這樣了。是時(shí)候探索 fish shell 了。

用法

要從你默認(rèn)的 shell 切換到 fish,請(qǐng)執(zhí)行以下操作:

  1. $ fish 
  2.  
  3. Welcome to fish, the friendly interactive shell 

你可以在 ~/.config/fish/config.fish 上找到默認(rèn)的 fish 配置(類似于 .bashrc)。如果它不存在,就創(chuàng)建它吧。

自動(dòng)建議

當(dāng)我輸入一個(gè)命令,它以淺灰色自動(dòng)建議一個(gè)命令。所以,我需要輸入一個(gè) Linux 命令的前幾個(gè)字母,然后按下 tab 鍵來完成這個(gè)命令。

如果有更多的可能性,它將會(huì)列出它們。你可以使用上/下箭頭鍵從列表中選擇列出的命令。在選擇你想運(yùn)行的命令后,只需按下右箭頭鍵,然后按下 ENTER 運(yùn)行它。

無需 CTRL+r 了!正如你已知道的,我們通過按 CTRL+r 來反向搜索 Bash shell 中的歷史命令。但在 fish shell 中是沒有必要的。由于它有自動(dòng)建議功能,只需輸入命令的前幾個(gè)字母,然后從歷史記錄中選擇已經(jīng)執(zhí)行的命令。很酷,是吧。

智能搜索

我們也可以使用智能搜索來查找一個(gè)特定的命令、文件或者目錄。例如,我輸入一個(gè)命令的一部分,然后按向下箭頭鍵進(jìn)行智能搜索,再次輸入一個(gè)字母來從列表中選擇所需的命令。

語法高亮

當(dāng)你輸入一個(gè)命令時(shí),你將注意到語法高亮。請(qǐng)看下面當(dāng)我在 Bash shell 和 fish shell 中輸入相同的命令時(shí)截圖的區(qū)別。

Bash:

Fish:

正如你所看到的,sudo 在 fish shell 中已經(jīng)被高亮顯示。此外,默認(rèn)情況下它將以紅色顯示無效命令。

基于 web 的配置方式

這是 fish shell 另一個(gè)很酷的功能。我們可以設(shè)置我們的顏色、更改 fish 提示符,并從網(wǎng)頁上查看所有功能、變量、歷史記錄、鍵綁定。

啟動(dòng) web 配置接口,只需輸入:

  1. fish_config 

手冊(cè)頁補(bǔ)完

Bash 和 其它 shells 支持可編程的補(bǔ)完,但只有 fish 可以通過解析已安裝的手冊(cè)來自動(dòng)生成它們。

為此,請(qǐng)運(yùn)行:

  1. fish_update_completions 

實(shí)例輸出將是:

  1. Parsing man pages and writing completions to /home/sk/.local/share/fish/generated_completions/ 
  2.  
  3.  3435 / 3435 : zramctl.8.gz 

禁用問候語

默認(rèn)情況下,fish 在啟動(dòng)時(shí)問候你(“Welcome to fish, the friendly interactive shell”)。如果你不想要這個(gè)問候消息,可以禁用它。為此,編輯 fish 配置文件:

  1. vi ~/.config/fish/config.fish 

添加以下行:

  1. set -g -x fish_greeting '' 

你也可以設(shè)置任意自定義的問候語,而不是禁用 fish 問候。

  1. set -g -x fish_greeting 'Welcome to OSTechNix' 

獲得幫助

這是另一個(gè)吸引我的令人印象深刻的功能。要在終端的默認(rèn) web 瀏覽器中打開 fish 文檔頁面,只需輸入:

  1. help 

官方文檔將會(huì)在你的默認(rèn)瀏覽器中打開。另外,你可以使用手冊(cè)頁來顯示任何命令的幫助部分。

  1. man fish 

設(shè)置 fish 為默認(rèn) shell

非常喜歡它?太好了!設(shè)置它作為默認(rèn) shell 吧。為此,請(qǐng)使用命令 chsh:

 

  1. chsh -s /usr/bin/fish 

在這里,/usr/bin/fish 是 fish shell 的路徑。如果你不知道正確的路徑,以下命令將會(huì)幫助你:

  1. which fish 

注銷并且重新登錄以使用新的默認(rèn) shell。

請(qǐng)記住,為 Bash 編寫的許多 shell 腳本可能不完全兼容 fish。

要切換回 Bash,只需運(yùn)行:

 

  1. bash 

如果你想 Bash 作為你的永久默認(rèn) shell,運(yùn)行:

  1. chsh -s /bin/bash 

各位,這就是全部了。在這個(gè)階段,你可能會(huì)得到一個(gè)有關(guān) fish shell 使用的基本概念。 如果你正在尋找一個(gè)Bash的替代品,fish 可能是一個(gè)不錯(cuò)的選擇。

責(zé)任編輯:龐桂玉 來源: Linux中國
相關(guān)推薦

2020-04-06 20:47:42

FishShellLinux

2019-03-18 13:00:15

LinuxFish ShellBash

2015-09-09 13:29:17

FISHShellLinux

2018-05-21 14:44:33

LinuxshellPython

2020-04-21 14:21:31

LinuxPython

2021-10-12 08:43:19

LinuxSambaWindows

2011-11-10 09:19:24

虛擬化云計(jì)算VMware

2019-11-26 09:20:47

LinuxJava

2021-09-11 15:41:55

UbuntuDropbox云服務(wù)

2017-03-29 16:18:11

LinuxUbuntuRedmine

2021-08-18 11:19:25

FedoraLinuxJava

2021-07-12 14:47:16

UbuntuZlib代碼

2022-07-14 14:37:05

Linux軟件開發(fā)工具

2023-07-27 17:41:02

BashZshFish

2020-12-18 08:00:00

Python開發(fā)Web

2021-11-28 06:33:24

Discord消息收發(fā)應(yīng)用 Linux

2012-05-21 10:31:06

LinuxVMware Tool

2018-03-28 08:30:01

Linux倉庫應(yīng)用程序

2022-11-09 07:40:18

2014-06-23 10:09:20

MacBook ProLinux
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)