Linux基础 终端美化
1 安装
#下载安装zsh
sudo apt-get install zsh
2 设置zsh为默认shell
chsh -s /bin/zsh
3 配置zsh
3.1 安装Oh-My-Zsh
配置zsh略微复杂,可以直接使用Oh-My-Zsh进行配置。
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 或使用国内个人复制github的镜像
sh -c "$(wget -O- https://gitee.com/pocmon/ohmyzsh/raw/master/tools/install.sh)"
有的主题必须使用powerline字体,通过以下命令安装:
sudo apt install powerline fonts-powerline
3.2 主题
Oh-My-Zsh默认安装了很多主题,位于目录.oh-my-zsh/themes
下。 通过zsh配置文件~/.zshrc
中的主题设置为自己喜欢的主题名字即可:
ZSH_THEME="agnoster"
3.3 推荐插件
命名高亮:zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
命令补全:zsh-autosuggestions
如图所示,输入命令时可提示自动补全(灰色部分),然后右方向键即可补全:
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
装完插件后,在.zshrc中配置这一段。
## 安装 zsh-syntax-highlighting 不同发行版安装位置不同修改路径
source ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
## 安装 zsh-autosuggestions 不同发行版安装位置不同修改路径
source ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
改完后重新加载.zshrc即可。
source ~/.zshrc
效果如图