一、安装zsh
# download
wget -O zsh.tar.xz https://sourceforge.net/projects/zsh/files/latest/download
mkdir zsh && unxz zsh.tar.xz && tar -xvf zsh.tar -C zsh --strip-components 1
cd zsh
# compile
./configure --prefix=$HOME
make
make install
正确执行完上面的步骤后,zsh就安装好了。
二、安装oh-my-zsh插件
oh-my-zsh
是一个很丝滑的软件,有一系列比较好用的插件,比如代码提示和高亮:zsh-autosuggestions
,zsh-syntax-highlighting
。
linux安装命令:
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
sh install.sh # 安装oh-my-zsh
安装插件, 可查看插件库,其中zsh-autosuggestions zsh-syntax-highlighting需要在github clone到~/.oh-my-zsh/custom/plugins 文件夹下
vim ~/.zshrc
# 修改zsh路径
export ZSH=$HOME/.oh-my-zsh
# 找到plugins,添加plugins,例如下:
plugins=(git
bundler
dotenv
macos
rake
rbenv
ruby
zsh-autosuggestions zsh-syntax-highlighting
)
添加插件,下载到$HOME/.oh-my-sh/custom/plugins/
文件夹下,命令:
# 添加 zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# 添加 zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
激活oh-my-zsh
source ~/.zshrc
如果后面换电脑有些命令还是需要,可以直接拷贝~/.zsh_history
文件到另一个电脑即可。