iTerm2 + Zsh + Oh-My-Zsh macOS上最强大的终端功能

你在默认终端纠结吗?希望你的终端看起来像这样吗?默认终端很糟糕?
如果你想让你的终端看起来像上图。来吧,这篇会适合你。
安装Homebrew

打开终端并粘贴。
1 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" |
下载iTerm2
- 转到下载页面https://www.iterm2.com/downloads.html
- 下载后,将文件拖放到我们的Application文件夹。
安装zsh
打开终端并粘贴。
1 | brew install zsh |
我们需要“oh-my-zsh”

Oh-My-Zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and a few things that make you shout…
--“Oh My ZSH!”
安装oh-my-zsh
安装时,oh-my-zsh将自动用zsh替换默认终端。
打开终端并粘贴。
1 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" |
使用颜色装饰 iTerm2

- 打开终端并粘贴
1 | $ cd Downloads |
打开已在第一部分下载的 iTerm2
转到 iTerm2 > Preferences > Profiles > Colors
单击右下角的 Color Presets…
单击 Import…
选择
material-design-colors.itermcolors
文件在 Load Presets... 选择 material-design-colors
管理插件
插件维基页面:https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins
在这种情况下,我想在我的zsh上启用插件'docker',所以我将运行此命令
1 | vi~ / .zshrc |
并键入“/ plugin”(不带引号)按Enter键,键入“i”字符并插入要添加的插件。
1 | . |
在这种情况下,我将添加docker插件,只需在我们的括号中添加“docker”。
1 | . |
在您满意后,按Esc
并键入:wq
,这意味着您保存文件并立即退出。并重启iTerm2。
添加别名(永久别名)
1 | vi ~/.zshrc |
如果我输入 dkps
,它将执行 docker ps