这是我这台 Mac 上真实在跑的全套终端配置,按「七层」分好类。每一项都有一句话说明 + 一行可复制的安装命令。目标只有一个:把终端从一个吓人的黑窗口,变成又快又顺手的工作台。Windows 同学请走 Windows Terminal + WSL2,本清单针对 macOS。想先弄懂每一层「为什么这么配」→ 七层归档总览。
第 0 步 装好它,后面的 brew install 才跑得通。帮我装这个并配好 .zshrc,它会逐项搞定。.zshrc 后执行 source ~/.zshrc 或新开一个窗口生效。# 装 Homebrew(中途会让你按一下回车、输一次开机密码) /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" # 装完让这个终端立刻认识 brew(Apple Silicon / M 系列芯片) echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)"
brew --version 验证。Intel 芯片的老 Mac 把上面两处 /opt/homebrew 改成 /usr/local。Oh My Zsh(curl 装)、两个 zsh-* 插件(git clone)、claude-hud(Claude Code 里装)不走 Homebrew,其余全靠它。# 终端 + prompt + 导航 + 全家桶,一次装完 brew install starship eza bat fd ripgrep fzf zoxide yazi autojump brew install --cask ghostty font-jetbrains-mono-nerd-font
Oh My Zsh 和两个 zsh 插件请到下面对应分层里单独复制安装命令。这两个是地基:Ghostty 是那个会发光的窗口(GPU 渲染、分屏、字体、主题都归它管);窗口里跑的是 zsh,Oh My Zsh 是 zsh 的「插件 + 别名管理框架」,后面的插件都挂在它上面。
brew install --cask ghostty~/.config/ghostty/config,存盘即时生效,无需重启。字体/主题/快捷键见下面对应分层。sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"~/.zshrc 里把要用的插件填进去:plugins=(git z node npm zsh-autosuggestions zsh-syntax-highlighting sudo history)。⚠️ 主题留空 ZSH_THEME="",prompt 交给 starship。这三样决定「第一眼观感」。starship 接管那行带目录和 git 分支的提示符;Nerd Font 是所有图标能显示的前提(没它 eza 图标、git 分支符号全是方块);主题负责配色。
brew install starship~/.zshrc 末尾加 eval "$(starship init zsh)";样式配置在 ~/.config/starship.toml(我用的是带色块的 powerline 风格,可直接照抄 ↓)。"$schema" = 'https://starship.rs/config-schema.json' format = """ [░▒▓](#a3aed2)\ [ ](bg:#a3aed2 fg:#090c0c)\ [](bg:#769ff0 fg:#a3aed2)\ $directory\ [](fg:#769ff0 bg:#394260)\ $git_branch\ $git_status\ [](fg:#394260 bg:#212736)\ $nodejs\ $rust\ $golang\ $php\ [](fg:#212736 bg:#1d2230)\ $time\ [ ](fg:#1d2230)\ \n$character""" [directory] style = "fg:#e3e5e5 bg:#769ff0" format = "[ $path ]($style)" truncation_length = 3 truncation_symbol = "…/" [directory.substitutions] "Documents" = " " "Downloads" = " " "Music" = " " "Pictures" = " " [git_branch] symbol = "" style = "bg:#394260" format = '[[ $symbol $branch ](fg:#769ff0 bg:#394260)]($style)' [git_status] style = "bg:#394260" format = '[[($all_status$ahead_behind )](fg:#769ff0 bg:#394260)]($style)' [nodejs] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [rust] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [golang] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [php] symbol = "" style = "bg:#212736" format = '[[ $symbol ($version) ](fg:#769ff0 bg:#212736)]($style)' [time] disabled = false time_format = "%R" style = "bg:#1d2230" format = '[[ $time ](fg:#a0a9cb bg:#1d2230)]($style)'
brew install --cask font-jetbrains-mono-nerd-fontfont-family = "JetBrainsMono Nerd Font"、font-size = 18。这是颜值层的地基,建议第一个装。# 写进 ~/.config/ghostty/config
theme = light:GitHub Light Default,dark:Catppuccin Mochaminimum-contrast = 4.5 可避免浅色背景下 Claude Code 的灰字糊到看不清。终端最累的就是「切目录、找文件」。zoxide / z 记住你去过的目录,敲一半关键词就跳过去;yazi(读音「鸭子」)是终端里的可视化文件管理器,像 Finder 一样用方向键浏览。
cd 聪明的智能跳转brew install zoxide~/.zshrc 加 eval "$(zoxide init zsh --cmd zi)",用 zi 关键词 跳转。我同时保留了 Oh My Zsh 的 z 插件和 autojump(brew install autojump),三套都能跳,挑顺手的用即可。brew install yazi~/.zshrc 加一个 y() 包装函数,退出 yazi 时自动把 shell 切到你最后所在的目录。yazi 内部还会调用下面全家桶里的 fd / ripgrep / fzf 做搜索,所以建议一起装。把上古的 ls / cat / find / grep 换成带颜色、带图标、更快的现代版。它们也是 yazi 搜索的底层依赖,一起装最省心。
brew install eza~/.zshrc 加别名:alias ls='eza --icons --group-directories-first'、alias ll='eza -lA --icons --git --time-style=relative'、alias lt='eza --tree --level=2 --icons'。brew install batbat 文件名 即可。可选别名 alias cat='bat --paging=never'。brew install fdfd 关键词,比 find . -name 好记太多。也是 yazi / fzf 的搜索后端。brew install ripgreprg 关键词。Claude Code 和 yazi 内部都靠它做全文搜索。brew install fzf~/.zshrc 加 [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh 启用快捷键。配合 fd/rg 一起最强。这些是 zsh 的「打字辅助」:边打边给灰字预测、命令对错变色、git 一堆短别名。它们写进 ~/.zshrc 的 plugins=(...) 里就生效。
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionszsh-autosuggestions 加进 plugins=(...)。git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlightingplugins=(...),建议放在列表最后。# 直接编辑 ~/.zshrc 的 plugins 行
plugins=(git z node npm zsh-autosuggestions zsh-syntax-highlighting sudo history)gst=status、gco=checkout);history 查历史命令;sudo 连按两下 Esc 给上条命令加 sudo。claude-hud 装在 Claude Code 里、不是 zsh 插件,所以单独归到「监控层」。作用是在 Claude Code 底部状态栏显示模型、上下文占用、5 小时 / 7 天额度恢复时间、当前任务等。
# 在 Claude Code 里输入斜杠命令
/plugin/plugin 插件市场里找到 claude-hud 安装,再把它设为 statusLine(我的 ~/.claude/settings.json 里已配好命令)。它跟终端无关,属于 AI 工具层。Ghostty 自带分屏 / 标签 / 下拉终端,不需要 tmux。下面这组快捷键写进 ~/.config/ghostty/config 就能用。
# 节选,完整版见我的 config
keybind = cmd+u=new_split:right
keybind = cmd+shift+d=new_split:down
keybind = cmd+t=new_tab
keybind = cmd+shift+f=toggle_split_zoomcmd+u 右分屏、cmd+shift+d 下分屏、cmd+shift+f 把当前分屏临时放大到全窗口(再按还原)。keybind = global:cmd+backquote=toggle_quick_terminal
quick-terminal-position = topglobal: 前缀,所以不在 Ghostty 时也能呼出。随手敲个命令、关掉不打断手头的活。