macOS 美化 iTerm2 方案
今天尝试给 iTerm2 换完主题后发现效果非常不错, 就发到博客上记录一下.
效果图
开始
前提
开始之前请安装好以下工具:
- iTerm2
(废话) - FiraCode (某些字符需要 powerline patched font 才能显示)
- Homebrew
- Git
把 iTerm2 字体改为 FiraCode
安装 Oh My Zsh
Oh My Zsh 是一个开源的 zsh 管理工具, 可以让你以极为简单配置, 就可以用上 Zsh 复杂繁琐的功能. 要安装 Oh My Zsh 只需要在终端输入以下命令
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
更改配色为 Dracula
个人比较喜欢 Dracula 配色, 链接: https://draculatheme.com/iterm
下载解压后 Preferences -> Profiles -> Color -> Color Presets -> Import… -> Dracula.itermcolors 完成
安装 spaceship 主题
下载主题
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt" --depth=1
链接到 oh-my-zsh
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"
修改 .zshrc
文件并生效
vim ~/.zshrc
# 主题修改为 spaceship
ZSH_THEME="spaceship"
# 生效
source ~/.zshrc
之后就是按需求修改主题风格了, 可以参考此配置文档: Options
个人不喜欢显示用户名, 所以添加了以下配置
SPACESHIP_USER_SHOW="false"
各位按需添加自己喜欢的就好
安装好用的插件
博主推荐安装以下插件:
- autojump
- zsh-autosuggestions
- zsh-syntax-highlighting
安装
autojump
: 实现文件夹间快速跳转, 想去哪个文件夹就 j + 文件夹名
brew install autojump
vim ~/.zshrc
# 找到 plugins, 添加
plugins=(autojump)
# 在末尾添加
[ -f /usr/local/etc/profile.d/autojump.sh ] && . /usr/local/etc/profile.d/autojump.sh
zsh-autosuggestions
: 输入命令时提示自动补全, 按键盘 → 即可补全
brew install zsh-autosuggestions
# 在末尾添加
source /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh
zsh-syntax-highlighting
: 人如其名, 语法高亮
brew install zsh-syntax-highlighting
# 在末尾添加
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
使插件生效
source ~/.zshrc
搞定收工!
本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!