iterm2 & oh-my-zsh 的配置与使用

368 阅读1分钟

对于开发人员来讲常用的是mac笔记本,而电脑中自带的终端又不好看还效率低,更推荐使用iterm2,那么iterm怎么配置呢? 我们一起来看一看。

官网下载地址

iterm2.com/index.html

直接傻瓜安装就可以

安装oh-my-zsh

1)先由bash切换到zsh

# 切换到bash
chsh -s /bin/bash

# 切换到zsh
chsh -s /bin/zsh

2)安装oh-my-zsh

第一种方式

# via curl
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# via wget
sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

第二种方式

# 下载 oh-my-zsh 源码
git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
# 并且把 .zshrc 配置文件拷贝到根目录下
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
# 让 .zshrc 配置文件生效
source ~/.zshrc

3)选择一款好看的主题

# 这是查看所有主题列表
ls ~/.oh-my-zsh/themes

也可以在github上直观的查看样式,github.com/ohmyzsh/ohm… 找到一款喜欢的,记住名字。

vim ~/.zshrc
ZSH_THEME="agnoster"
source ~/.zshrc

4)安装字体

这个时候你就会发现,终端的样式已经改了,会有很多样式显示不出来,这就需要安装特定字体

# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts

然后修改终端默认字体

菜单栏 -> Profiles -> Open Profiles -> Edit Profiles -> 选择 Text 把底部字体更改为Meslo LG for Powerline

然后所有显示就都正常了

安装插件

zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
vim ~/.zshrc
# 找到plugins=(git),修改为 plugins=(git zsh-autosuggestions)
source ~/.zshrc

zsh-syntax-highlighting

cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
vim ~/.zshrc
#修改plugins=(git zsh-autosuggestions zsh-autosuggestions)
source ~/.zshrc

然后就一切都妥了!