1、简介
Zsh 是一个为交互使用而设计的shell,也是一种强大的脚本语言。 官网:Z-shell
2、安装
sudo apt-get install zsh
3、切换
# 查看当前shell
echo $SHELL
# 切换为 z-shell,重启之后生效
chsh -s /usr/bin/zsh
# 切回 bash
chsh -s /usr/bash
4、安装oh-my-zsh,配置zsh
4.1 下载oh-my-zsh
oh-my-zsh包含了诸多插件,允许用户客制化配置zsh,官网:oh-my-zsh
# 下载
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
4.2 安装插件
# zsh的主题和插件位置分别为
home/user/.oh-my-zsh/custom/theme
home/user/.oh-my-zsh/custom/plugins
4.2.1 安装自动补全插件zsh-autosuggestions
# 下载位置一般为:home/user/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# vim编辑zshrc
vim ~/.zshrc
# 配置zshrc,找到plugins,更改为如下内容,没有plugins则自行添加
plugins=(git
zsh-autosuggestions # 插件之间使用空格隔开
)
# 更新zshrc
source ~/.zshrc
4.2.2 安装纠错插件zsh-syntax-highlighting
# 下载位置一般为:home/user/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 其余同上
4.3 安装主题p10k,可自行选择
# 下载位置一般为:home/user/.oh-my-zsh/custom/theme
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
# 编辑~/.zshrc,找到ZSH_THEME,没有ZSH_THEME则自行创建
ZSH_THEME="powerlevel10k/powerlevel10k"
# 更新zshrc
source ~/.zshrc
配置p10k,一般在上一步更新之后就会自动进入配置,重置则执行
p10k configure
问题
1、安装zsh后无法识别conda
vim ~/.zshrc
# 添加
export PATH=/home/username/anaconda3/bin:$PATH
source ~/.zshrc
重启生效