跳转至

一份年幼无知的 zsh 配置

在笔者大一刚结束时, 自己捣鼓了很久的zsh配置, 直至大三转入fish"邪教".

  • 使用设备: MacbookPro(M2)
  • 电脑版本: Sequoia 14.0 (23A344)
  • 配置目的: 我的mac默认终端是zsh, 但缺乏oh-my-zsh的加持, 它显得不够高端, 遂决定“升级”

直接从官网下载iTerm.app软件: https://iterm2.com/

Danger

本文初稿写于2023年, 是笔者“稚嫩时期”的配置, 因此不具备“潮流性”.

现在(2025.11)更推荐的是fish shell, 详见本站《fish shell 配置》这一节.

oh-my-zsh安装

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

当然, 你也可以使用 git clone 进行下载, 两者是一个意思, 此处略去

FiraCode字体安装

安装字体:

Bash
1
2
brew tap homebrew/cask-fonts
brew install font-fira-code --cask

插件安装

pure prompt

Bash
1
2
3
4
brew install pure
# .zshrc
autoload -U promptinit; promptinit
prompt pure

fuzzy finder

Bash
1
2
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

高亮+自动补全+跳转

很显然:一路y就好

使用快捷键:ctrl+R

⚠️下面这三个先下载后配置, 然后刷新zsh!

下载:

(1) zsh-syntax-highlighting

Bash
1
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

(2) zsh-autosuggestions

Bash
1
 git clone https://github.com/zsh-users/zsh-autosuggestions ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

(3) autojump

Bash
1
brew install autojump

配置:

Bash
1
vim ~/.zshrc
Bash
1
2
3
4
5
6
plugins=(
  git
  zsh-syntax-highlighting
  zsh-autosuggestions
  autojump
)

生效:

Bash
1
source ~/.zshrc

iTerm2 配置清单

  • 上面介绍的插件
  • 窗口默认显示长宽比:100:50
  • 窗口显示透明度:80%
  • 显示窗体(悬浮窗):cpu使用率 + 内存使用率 + 当前git地址 + 查找

快捷命令:

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