iTerm + zsh

安装 iTerm 2

1
brew cask install iterm2

安装完成后即可使用iterm2进行后续操作

安装 zsh

1
brew install zsh zsh-completions

安装 Git

1
brew install git

安装 Oh My Zsh

1
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

安装设置字体

Meslo LG M Regular for Powerline

设置主题

ZSH_THEME=”agnoster”/“ys”

插件

语法高亮提示

1
2
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git 
echo "source ${(q-)PWD}/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc

超强自动补全

zsh-autosuggestions

1
2
3
4
5
//安装
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

//配置 .zshrc
plugins配置,增加zsh-autosuggestions

跳转目录

  1. autojump

brew install autojump

安装完在ZSH下不可用,需在.zshrc下添加以下命令

1
2
3
4
5
6
7
8
9
10
11
[[ -s brew --prefix/etc/autojump.sh ]] && . brew --prefix/etc/autojump.sh

source ~/.bash_profile

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

X source ~/.oh-my-zsh/plugins/incr/incr*.zsh

export LC_ALL=en_US.UTF-8

export LANG=en_US.UTF-8

  1. z
    oh-my-zsh中自带,直接在plugins中添加

我安装的插件

z gitfast zsh-autosuggestions zsh-syntax-highlighting

快捷键

左右跳转

按住option + → or ←键,在命令的开始和结尾跳转切换

打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles → Keys → Load Preset… → Natural Text Editing

问题

oh-my-zsh agnoster主题特殊字符显示异常问题

.oh-my-zsh/themes/agnoster.zsh-theme:72: parse error near <<<

解决方案:

1
2
3
cd ~/.oh-my-zsh/themes

git checkout d6a36b1 agnoster.zsh-theme

一些命令无法执行

在zshrc文件中添加profle文件的支持

Mac OS

1
source ~/.bash_profile

Ubuntu

1
source ~/.profile