1.安装zsh
编译安装
在官网下载源码包:https://sourceforge.net/projects/zsh/
安装zsh
$ tar -zxvf zsh-5.7.1.tar.xz
$ ./configure
$ make && make install
直接安装
sudo apt install zsh
查看安装是否成功
$ cat ~/.zshrc --version
$ cat /home/$User/.zshrc
cat (GNU coreutils) 8.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.Written by Torbjörn Granlund and Richard M. Stallman.
2.更改默认Shell(可忽略)
默认的shell是bash,需要修改成zsh。先写入shells
$cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/dash
/bin/bash
/bin/rbash
/bin/zsh
/usr/bin/zsh
/usr/bin/screen
更改默认shell ,跟改后需要重开终端
$chsh -s /usr/local/bin/zsh
查看当前shell
$ echo $SHELL
/usr/local/bin/zsh
3.基于oh-my-zsh进行配置zsh
omz是类似与构建zsh框架的东西,使用omz就行布局配置
ubuntu:
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
centos
wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh && ./install.sh
安装后结果如下:
4.更改OMZ主题
默认是robbyrussell,我们可以更改为ys(界面比较清晰),下面是配置文件,标粗的位置更改为ys即可
vim ~/.zshrc 找到 ZSH_THEME="robbyrussell" 改为ZSH_THEME="ys"
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH# Path to your oh-my-zsh installation.
export ZSH="/root/.oh-my-zsh"# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#修改主题
ZSH_THEME="robbyrussell"~~~~~~
thems所有的主题在这个目录下 :/root/.oh-my-zsh/themes
5. zsh装插件
1. 插件一,高亮错误输入:zsh-syntax-highlighting
在git上获取到插件
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
$ mv zsh-syntax-highlighting ~/.oh-my-zsh/plugins/zsh-syntax-highlighting
在配置文件中添加,~/.oh-my-zsh,编译~/.zshrc
$ echo "plugins=(zsh-syntax-highlighting)" >> ~/.zshrc
$ source ~/.zshrc