iterm2 美化
iTerm2 美化指南
好看的终端是会让人有每天使用的冲动,下面是一些 iTerm2 美化的步骤和建议: 这里不赘述iterm2的安装,假设你已经安装好了 iTerm2。
oh-my-zsh 安装
首先安装 zsh 和 oh-my-zsh:
# 安装 zsh
brew install zsh
# 安装 oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/oh-my-zsh/master/tools/install.sh)"
选择主题
打开 ~/.zshrc 文件,找到 ZSH_THEME 变量,将其设置为你喜欢的主题,例如:
ZSH_THEME="agnoster"
保存并关闭文件,然后运行以下命令使更改生效:
source ~/.zshrc
安装 Powerline 字体
为了让主题显示得更好看,建议安装 Powerline 字体:
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
安装完成后,打开 iTerm2,进入 Preferences -> Profiles -> Text,将字体设置为刚才安装的 Powerline 字体(例如 Hack Nerd Font)。
配置 iTerm2 颜色方案
你可以从 iTerm2 Color Schemes 下载喜欢的颜色方案。下载后,双击 .itermcolors 文件即可导入到 iTerm2 中。然后在 Preferences -> Profiles -> Colors 中选择你导入的颜色方案。
安装插件
你可以通过 oh-my-zsh 安装一些有用的插件,例如 zsh-syntax-highlighting 和 zsh-autosuggestions:
# 安装 zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
# 安装 zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
然后在 ~/.zshrc 文件中添加这些插件:
plugins=(git zsh-syntax-highlighting zsh-autosuggestions)
保存并关闭文件,然后运行以下命令使更改生效:
source ~/.zshrc
其他建议
- 使用
tmux进行终端分屏和会话管理。# 等我研究会再写一篇 tmux 美化指南。 - 自定义提示符,添加 Git 状态显示等信息。
- 定期更新 oh-my-zsh 和插件以获取最新功能和修复。