iTerm2 和 Oh My Zsh 的配置

iTerm2 和 Oh My Zsh 的配置


2018-09-30

首先安装 iTerm2 :

1
brew install iterm2

安装 oh-my-zsh 可以让 iterm2 变的好看点。

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

安装 Power Line:

1
pip3 install powerline-status -i https://pypi.doubanio.com/simple/

安装 Powerline Fonts:

1
2
3
git clone https://github.com/powerline/fonts.git
cd fonts
./install.sh

设置 iTerm2 字体,在 iTerm2 -> Preferences -> Profiles -> Text -> Change Font 中将字体设置为 ‘12pt Meslo LG M Regular for Powerline’ 。

设置配色方案:

1
2
3
git clone https://github.com/altercation/solarized
cd solarized/iterm2-colors-solarized/
open .

双击两个配色方案,会自动导入 iTerm2 。

进入 iTerm2 -> Preferences -> Profiles -> Colors -> Color Presets 设置为 Solarized Dark 。

安装主题

修改 .zshrc ,设置 ZSH_THEME="agnoster" 。重启 iTerm2 看是否生效,如未生效可进入主题目录 .oh-my-zsh/themes 检查是否存在 agnoster.zsh-theme,如果没有可去 https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster 指定官方库下载。

安装设置插件

1
2
cd ~/.oh-my-zsh/custom/plugins/
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

修改 .zshrc 中 plugins 为:

1
2
3
4
5
6
plugins=(
git
zsh-syntax-highlighting
mvn
sublime
)

其他设置

进入 iTerm2 -> Preferences -> Profiles 设置 Columns:80 ,Rows:44 。

最后重启 iTerm2 即可。

有时候我们在使用 brew 的时候会报错,如: LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to …… ,这是由于我们使用系统自带的 curl 和 libressl 版本过旧,使用 brew 安装这两个软件,并设置环境变量即可。

1
2
3
brew install curl libressl
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/libressl/bin:$PATH"' >> ~/.zshrc

安装日志真贴心,提示的不能更详细

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
==> curl
curl is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have curl first in your PATH run:
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.zshrc

For compilers to find curl you may need to set:
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"

==> libressl
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
/usr/local/etc/libressl/certs

and run
/usr/local/opt/libressl/bin/openssl certhash /usr/local/etc/libressl/certs

libressl is keg-only, which means it was not symlinked into /usr/local,
because LibreSSL is not linked to prevent conflict with the system OpenSSL.

If you need to have libressl first in your PATH run:
echo 'export PATH="/usr/local/opt/libressl/bin:$PATH"' >> ~/.zshrc

For compilers to find libressl you may need to set:
export LDFLAGS="-L/usr/local/opt/libressl/lib"
export CPPFLAGS="-I/usr/local/opt/libressl/include"