程序员

【美化终端】安装配置zsh和oh-my-zsh

2020-06-26  本文已影响0人  Sp0n

参考链接:

【一】让机器能够解析github的域名

  1. DNS域名解析查询:https://www.ipaddress.com/
  2. 打开上面网站查询以下域名对应的ip
github.com
assets-cdn.github.com
github.global.ssl.fastly.net
codeload.github.com
raw.githubusercontent.com
  1. 修改/etc/hosts
sudo vim /etc/hosts
# 添加刚刚查询到的ip  域名 
:wq            #保存退出
source ~/.bashrc  # 重新加载.bashrc
/etc/hosts

【二】安装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
# 重新打开终端
成功安装oh-my-zsh

【四】修改zsh主题(agnoster)

  1. 安装Powerline Fonts
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
  1. 安装 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
安装字体
  1. 修改~/.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
保存退出
image.png

【五】添加插件

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
在plugin中添加zsh-autosuggestions和zsh-syntax-highlighting
:wq  #保存退出
source ~/.zshrc
添加插件

【六】使用命令别名简化命令

【七】知道方法后就可以自己定制自己的zsh了,喜欢的就点个赞吧

上一篇 下一篇

猜你喜欢

热点阅读