Zsh¶
Zsh是一款拥有高度自定义性的Shell,它具有强大的自动补全、语法高亮,并且由于Oh My Zsh的支持,拥有海量主题与插件,特别适合用于美化。
安装¶
Zsh¶
以下命令用于安装Zsh与部分推荐扩展。
- Debian:
sudo apt install zsh zsh-autosuggestions zsh-syntax-highlighting - Fedora:
sudo dnf install zsh zsh-autosuggestions zsh-syntax-highlighting - Arch:
sudo pacman -S zsh zsh-completions zsh-autosuggestions zsh-syntax-highlighting
安装好后,您可以运行chsh -s /bin/zsh来设置Zsh为默认终端。
部分发行版源的zsh包,在初次运行zsh时,会询问您想要如何配置.zshrc(Zsh的配置文件)。我们建议您输入2来选择(2) Populate your ~/.zshrc with the configuration recommended by the system administrator and exit (you will need to edit the file by hand, if so desired).(默认推荐配置)。
Oh My Zsh¶
Oh My Zsh能够用于管理.zshrc配置文件,简化Zsh的配置过程,并通过丰富的插件和主题生态,极大地提升终端的使用效率和视觉体验。
在安装之前,您首先需要使用包管理器安装Git(包名git)。
一键安装¶
运行以下一键安装脚本即可。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 或者
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
网络问题
该脚本与 https://install.ohmyz.sh 的脚本本质相同,均需要从Github克隆Zsh仓库,因此可能需要较好的网络环境。
手动安装¶
若您因为网络原因无法使用一键安装,您可以采用手动安装。
# 克隆仓库(使用gh-proxy以规避网络问题)
git clone https://gh-proxy.com/https://github.com/ohmyzsh/ohmyzsh ~/.oh-my-zsh
# 或者使用Gitee(需要登录)
# git clone https://gitee.com/mirrors/ohmyzsh ~/.oh-my-zsh
# 备份.zshrc
mv ~/.zshrc ~/.zshrc.orig
# 使用Oh My Zsh提供的模板
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 应用Oh My Zsh
zsh
主题¶
大部分Zsh主题可以在Github上找到,同时,Oh My Zsh也拥有大量的预置主题。大部分主题均提供了安装脚本,此处我们以Powerlevel10k为例。
# 克隆仓库
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ~/powerlevel10k
# 写入.zshrc
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>~/.zshrc