iTerm2和oh-my-zsh联合打造Mac终端
(一)iTerm2
1.安装并设置为默认终端
- 下载并安装
iTerm2 - 将
iTerm2设置为默认终端:iTerm2 -> Make iTerm2 Default Term
2.背景图片设置
- 选择背景图片:
iTerm2 -> Preferences -> Profiles -> Window -> Background Image -> Enabled
- 设置透明度:通过
Blending调节壁纸的透明度,透明度越高越透明
效果图:
3.字体设置
- 通过
pip安装PowerLine:
# 通过HomeBrew安装python3,获取easy-install
brew install python3
# 通过pip获取PowerLine
pip install powerline-status --user
- 在合适位置创建空目录,执行如下命令安装字体库:
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
./install.sh
# Powerline fonts installed to /Users/dragonbaby308/Library/Fonts
cd /Users/dragonbaby308/Library/Fonts
- 设置字体:
iTerm2 -> Preferences -> Profiles -> Text -> Font -> 选择字体
4.配色设置
- 在合适位置创建空目录,执行如下命令下载配色:
git clone https://github.com/altercation/solarized
cd solarized/iterm2-colors-solarized/
# 打开Finder
open .
- 在打开的窗口中,双击
Solarized Dark.itermcolors和Solarized Light.itermcolors即可安装明暗两种配色:
- 设置配色:
iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets
(二)oh-my-zsh
1.安装
Mac默认使用dash作为终端,通过chsh -s /bin/zsh将默认终端修改为zsh- 安装
oh-my-zsh:
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2.主题下载与配置
- 创建空目录,执行如下命令:
git clone https://github.com/fcamblor/oh-my-zsh-agnoster-fcamblor.git
cd oh-my-zsh-agnoster-fcamblor/
# 执行该命令会将主题拷贝到oh-my-zsh的themes目录下,当然你也可以手动进行
./install
- 修改配置文件:
vi ~/.zshrc
# 将主题配置为ys
ZSH_THEME="ys"
source ~/.zshrc使配置生效
3.插件安装
- 插件安装
# 语法高亮插件
sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
# 命令补全插件
sudo git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
- 修改配置文件:
vi ~/.zshrc
# zsh-syntax-highlighting必须是最后一个!
plugins=(git, zsh-autosuggestions, zsh-syntax-highlighting)
source ~/.zshrc使配置生效
如果觉得自动补全颜色与背景色难以区分,可以在
iTerm2 -> Preferences -> Profiles -> Colors -> 右侧ANSI Colors -> Bright第一行中配置自动补全的字体颜色。