本文將向你展現如何在 Fedora 的命令行解釋器(CLI)Shell 中設置一些強大的工具。若是使用bash(默認)或zsh,Fedora 可以讓你輕鬆設置這些工具。linux
這須要一些已安裝的軟件包。在 Fedora 工做站上,運行如下命令:c++
sudo dnf install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
複製代碼
在 Silverblue 上運行:git
sudo rpm-ostree install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
複製代碼
注意:在 Silverblue 上,你須要從新啓動才能繼續。github
你能夠經過安裝新字體使終端面目一新。爲何不使用能夠同時顯示字符和圖標的字體呢?shell
打開一個新終端,而後鍵入如下命令:vim
git clone https://github.com/ryanoasis/nerd-fonts ~/.nerd-fonts
cd .nerd-fonts
sudo ./install.sh
複製代碼
在工做站上,使用如下命令進行安裝:ruby
sudo dnf fontawesome-fonts
複製代碼
在 Silverblue 上鍵入:bash
sudo rpm-ostree install fontawesome-fonts
複製代碼
Powerline 是 vim 的狀態行插件,併爲其餘幾個應用程序也提供了狀態行和提示符,包括 bash、zsh、tmus、i三、Awesome、IPython 和 Qtile。你也能夠在官方文檔站點上找到更多信息。框架
要在 Fedora 工做站上安裝 Powerline 實用程序,請打開一個新終端並運行:curl
sudo dnf install powerline vim-powerline tmux-powerline powerline-fonts
複製代碼
在 Silverblue 上,命令更改成:
sudo rpm-ostree install powerline vim-powerline tmux-powerline powerline-fonts
複製代碼
注意:在 Silverblue 上,你須要從新啓動才能繼續。
要使 Powerline 默認處於活動狀態,請將下面的代碼放在 ~/.bashrc
文件的末尾:
if [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/share/powerline/bash/powerline.sh
fi
複製代碼
最後,關閉終端並打開一個新終端。它看起來像這樣:
Oh-My-Zsh 是用於管理 Zsh 配置的框架。它捆綁了有用的功能、插件和主題。要了解如何將 Zsh 設置爲默認外殼程序,請參見這篇文章。
在終端中輸入:
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
複製代碼
或者,你也能夠輸入如下內容:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
複製代碼
最後,你將看到以下所示的終端:
恭喜,Oh-my-zsh 已安裝成功。
安裝後,你能夠選擇主題。我喜歡使用 powerlevel10k。優勢之一是它比 powerlevel9k 主題快 100 倍。要安裝它,請運行如下命令行:
git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/themes/powerlevel10k
複製代碼
並在你的 ~/.zshrc
文件設置 ZSH_THEME
:
ZSH_THEME=powerlevel10k/powerlevel10k
複製代碼
關閉終端。再次打開終端時,powerlevel10k 配置嚮導將詢問你幾個問題以正確配置提示符。
完成 powerline10k 配置嚮導後,你的提示符將以下所示:
若是你不喜歡它。你能夠隨時使用 p10k configure
命令來運行 powerline10k 嚮導。
插件存儲在 .oh-my-zsh/plugins
文件夾中。要激活插件,你須要編輯 ~/.zshrc
文件。安裝插件意味着你建立了一系列執行特定功能的別名或快捷方式。
例如,要啓用 firewalld 和 git 插件,請首先編輯 ~/.zshrc
:
plugins=(firewalld git)
複製代碼
注意:使用空格分隔插件名稱列表。
而後從新加載配置:
source ~/.zshrc
複製代碼
要查看建立的別名,請使用如下命令:
alias | grep firewall
複製代碼
我建議安裝語法高亮和語法自動建議插件。
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
複製代碼
將它們添加到文件 ~/.zshrc
的插件列表中。
plugins=( [plugins...] zsh-syntax-highlighting zsh-autosuggestions)
複製代碼
從新加載配置。
source ~/.zshrc
複製代碼
查看結果:
colorls
是一個 ruby gem,可以使用顏色和超棒的字體圖標美化終端的 ls
命令。你能夠訪問官方網站以獲取更多信息。
由於它是個 ruby gem,因此請按照如下簡單步驟操做:
sudo gem install colorls
複製代碼
要保持最新狀態,只需執行如下操做:
sudo gem update colorls
複製代碼
爲防止每次輸入 colorls
,你能夠在 ~/.bashrc
或 ~/.zshrc
中建立別名。
alias ll='colorls -lA --sd --gs --group-directories-first'
alias ls='colorls --group-directories-first'
複製代碼
另外,你能夠爲 colorls
的選項啓用製表符補完功能,只需在 shell 配置末尾輸入如下行:
source $(dirname ($gem which colorls))/tab_complete.sh
複製代碼
從新加載並查看會發生什麼:
via: fedoramagazine.org/tuning-your…
做者:George Luiz Maluf 選題:lujun9972 譯者:wxy 校對:wxy