参考链接:
- 作者:iCodes_ 链接:https://www.jianshu.com/p/0d32ed87c8a8
- 作者:加油_努力_奋斗 链接:https://www.jianshu.com/p/db5e2833e0fc
【一】让机器能够解析github的域名
- DNS域名解析查询:https://www.ipaddress.com/
- 打开上面网站查询以下域名对应的ip
github.com
assets-cdn.github.com
github.global.ssl.fastly.net
codeload.github.com
raw.githubusercontent.com
- 修改/etc/hosts
sudo vim /etc/hosts
# 添加刚刚查询到的ip 域名
:wq #保存退出
source ~/.bashrc # 重新加载.bashrc

【二】安装zsh
sudo apt install zsh #安装zsh
chsh -s `which zsh` #将终端从默认的bash换成zsh
#重新打开terminal就能看到效果
【三】安装oh-my-zsh
- 自动安装
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# 重新打开终端
- 手动安装
# 下载
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
# 备份zshrc
cp ~/.zshrc ~/.zshrc.bak
# 覆盖zshrc
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 重新打开终端

【四】修改zsh主题(agnoster)
sudo apt-get install gcc g++ zlib1g-dev openssl make
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
sudo python ez_setup.py --insecure
sudo easy_install pip # 安装pip
pip install powerline-status # 安装Powerline
- 安装 Meslo 字体库
# clone,如果太慢的话,可以先将项目克隆到gitee,通过gitee进行clone,详细看参考链接2
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

- 修改~/.zshrc
vim ~/.zshrc
// 修改ZSH_THEME="agnoster"
:wq # 保存退出
source ~/.zshrc


可能出现报错:zsh (anon):12: character not in range
- 解决方法
vim ~/.bashrc
在文件尾添加
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
`esc` :wq
source .bashrc
source .zshrc


【五】添加插件
- 语法高亮插件zsh-syntax-highlighting安装
git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
- 自动提示插件zsh-autosuggestions安装
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- 修改~/.zshrc
在plugin中添加zsh-autosuggestions和zsh-syntax-highlighting
:wq #保存退出
source ~/.zshrc

【六】使用命令别名简化命令
-
修改~/.zshrc
-
保存退出
alias使用
效果
【七】知道方法后就可以自己定制自己的zsh了,喜欢的就点个赞吧
-
更多自带主题可以在~/.oh-my-zsh/themes下查看
-
网上还有很多插件供开发者下载使用
https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview -
zsh和omz尽量安装在自己常用的用户上,我这里直接安装配置在root用户上其实是不太好的。
-
如有不对或不懂的地方,欢迎私信指正~
网友评论