iTerm2 + Oh My Zsh 配置终端利器

1,183 阅读1分钟

使用iTerm2 + Oh My Zsh来配置一个属于自己的舒适终端。文本使用 Homebrew 安装软件,vim编辑文件;

1. 安装 iTerm2

使用Homebrew安装iterm2

brew cask install iterm2

2. 配置 iTerm2 主题(Solarized Dark theme

个人喜欢Solarized Dark theme,就以这套主题为例;

  1. 下载 Solarized Dark theme
  2. 下载完成后配置主题
  • 打开 Preferences 配置界面,然后Profiles -> Colors -> Color Presets, 在下拉列表中选择 Import,选择刚才解压的solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件,
  • 导入成功后在 Color Presets下选择 Solarized Dark 主题

3. 配置 Oh My Zsh

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

// 2. 设置为当前用户的默认 Shell
chsh -s /bin/zsh

// 3. 修改主题 (i进入编辑模式 修改 ZSH_THEME="agnoster" esc键,退出编辑,:wq保存退出)
vim ~/.zshrc

4. 安装语法高亮插件(zsh-syntax-highlighting)

// 1. 安装
brew install zsh-syntax-highlighting

// 2. 配置
vim ~/.zshrc
// 在最后一行增加下面配置
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

20211204131437.jpg

5. 配置 Meslo 字体

  1. 下载 Meslo字体,安装;
  2. 打开 Preferences 配置界面,然后Profiles -> Text -> Font -> Chanage Font,选择 Meslo LG M Regular for Powerline 字体;

6. 解决VScode终端乱码问题

20211204130006.jpg

在编辑器“设置”中添加终端字体 Meslo LG M for Powerline 就👌了。

20211204130402.jpg

常用快捷键命令

command + t 新建标签
command + w 关闭标签
command + enter 切换全屏
command + f 查找
command + d 水平分屏
command + shift + d 垂直分屏
command + option + 方向键 command + [ 或 command + ]    切换屏幕
command + 数字 command + 左右方向键    切换标签
command + ; 查看历史命令
command + shift + h 查看剪贴板历史
ctrl + u    清除当前行
ctrl + l    清屏
ctrl + a    到行首
ctrl + e    到行尾
ctrl + f/b  前进后退
ctrl + p    上一条命令
ctrl + r    搜索命令历史