一、zsh配置
1.安装zsh
sudo apt install zsh
2.将 zsh 设置为默认 Shell
chsh -s /bin/zsh
3.重启
reboot
打开终端,出现Z Shell配置页面时按“2”键,会创建一个 ~/.zshrc 配置文件
4.安装zsh-theme-powerlevel9k主题,zsh-autosuggestions和zsh-syntax-highlighting插件
sudo apt install zsh-theme-powerlevel9k zsh-autosuggestions zsh-syntax-highlighting
注:Ubuntu 18无法通过此方法安装zsh-autosuggestions,后续的配置也需要去掉相关部分
sudo apt install zsh-theme-powerlevel9k zsh-syntax-highlighting
5.用gedit打开.zshrc文件
gedit ~/.zshrc
在最后添加如下内容:
# 设置方向键选择补全
zstyle ':completion:*' menu select
# 配置别名
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# 配置通配符
setopt nonomatch
# 主题与插件配置
source /usr/share/powerlevel9k/powerlevel9k.zsh-theme
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
注:Ubuntu 18去掉
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
安装完成
二、Oh My Zsh配置
1.安装Oh My Zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
如果无法安装用如下方法安装:
国内源下载Oh My Zsh:
wget https://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh
给install.sh添加权限:
chmod +x install.sh
安装:
./install.sh
2.用gedit打开.zshrc文件
gedit ~/.zshrc
在最后添加如下内容:
# 配置通配符
setopt nonomatch
# 配置插件
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
注:Ubuntu 18去掉
source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
可在官网查看主题和插件
主题:
https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
插件:
https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
在第11行更改ZSH_THEME参数的值可以更改主题,如切换到ys主题:
ZSH_THEME="ys"
在第73行更改plugins参数的值可以启用插件
3.Ubuntu 18安装zsh-autosuggestions
下载插件:
git clone https://gitee.com/hailin_cool/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
用gedit打开.zshrc文件:
gedit ~/.zshrc
在第73行更改plugins参数的值,改为
plugins=(git zsh-autosuggestions)
卸载Oh My Zsh:
uninstall_oh_my_zsh