iTerm2 + oh my zsh + solarized +
翻译一篇iTerm2+OMZ等配置的文章
![](https://img.haomeiwen.com/i1965739/5d353fbad32d6b9a.png)
如何安装
iTerm2
- 下载 安装 iTerm2 (它比macOS内置的Terminal色彩更绚丽).
�选择以下主题配置方案
![](https://img.haomeiwen.com/i1965739/99b28d6cfc0146ed.png)
下载并安装主题包, 这些主题会被安装到iTerm2。iTerm -> preferences -> profiles -> colors -> load presets。
Oh my zsh
关于OMZ想了解更多,请访问: https://github.com/robbyrussell/oh-my-zsh
用curl安装OMZ
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
安装完成,编辑 ~/.zshrc
设置 ZSH_THEME="agnoster"
安装主题需要的字体文件补丁
- Meslo (第一张图的显示字体). 下载安装字体.
- [其他 @ powerline 字体](https://github.com/powerline/fonts)
在iTerm中应用字体 (我自己设置14px字体大小) (iTerm -> Preferences -> Profiles -> Text -> Change Font).
重启 iTerm2后,修改的配置会生效
进一步优化iTerm2
以下:
- 自动建议
- 用"→" "←"使光标移动一个单词
- iTerm前缀减短模式
- 声明高亮
自动建议 (oh-my-zsh)
![](https://img.haomeiwen.com/i1965739/da84f3c85bab74f3.png)
根据以下步骤安装: https://github.com/tarruda/zsh-autosuggestions#oh-my-zsh
![](https://img.haomeiwen.com/i1965739/58ceb054fa2d4eed.png)
如果自动建议没有生效, 那么极有可能是因为主题配置的问题。"iTerm -> Preferences ->Profiles-> Colors tab",检查Black Bright, 自动建议框的背景颜色和这个一样。所以我把Solarized Dark Black Bright 设置为 "586e75".
设置光标移动一个单词
默认情况下,光标移动一个单词 (option + → or ←) 是不生效的. "iTerm -> Preferences -> Profiles -> Keys". 点击+ 注册以下快捷键
Option + right
⌥→
Send Escape Sequence
f
Option + left
⌥←
Send Escape Sequence
b
iTerm前缀减短模式
![](https://img.haomeiwen.com/i1965739/7dff1c0e881035ff.png)
![](https://img.haomeiwen.com/i1965739/f8c63f0bde3ae3c8.png)
默认情况下,iTerm会像上图一样显示“user@hostname” . 这样会让你的命令过长。在 ~/.zshrc
里,设置 DEFAULT_USER
成你的用户名,用户名为 “user@hostname” 的hostname.比如如上图,那么设置“DEFAULT_USER=sam”. 设置成功后,你可以用命令whoami
来检查自己用户名
声名高亮
brew install zsh-syntax-highlighting
如果你不喜欢用homebrew安装, 按以下说明步骤安装吧 安装说明.
安装完成后
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
加到.zshrc
的末尾,然后重启iTerm生效。