Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具
安装所需工具
Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
brew install --cask ghosttyTerminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
brew install fish starship fzf zoxide eza bat lazygitTerminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
command -v fish starship fzf zoxide eza bat lazygit/opt/homebrew/bin/。其他环境先运行 command -v fish,再把实际路径写进 Ghostty 配置。技术栈的职责分工
层级 | 工具 | 职责 |
|---|---|---|
终端模拟器 | Ghostty | 创建终端窗口,处理字体、主题、快捷键和 Shell integration。 |
Shell | Fish | 提供自动建议、补全、环境变量、函数和交互式初始化。 |
Prompt | Starship | 显示目录、Git 状态、语言运行时和其他上下文。 |
搜索与跳转 | fzf、zoxide | 模糊搜索候选项,根据使用记录跳转目录。 |
文件查看 | eza、bat | 展示目录内容,预览带语法高亮的文本。 |
Git TUI | Lazygit | 处理暂存、提交、diff、分支和常见 Git 操作。 |
配置 Ghostty
Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (text)
~/Library/Application Support/com.mitchellh.ghostty/config.ghosttyTerminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (ini)
command = /opt/homebrew/bin/fish
shell-integration = fishTerminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (ini)
font-family = "Maple Mono NF CN"
font-size = 15
theme = Kanagawa Wave
window-padding-x = 14
window-padding-y = 10Ctrl + `` 打开顶部终端,再按一次将它隐藏。Quick Terminal 在打开和隐藏之间保留当前会话状态。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (ini)
quick-terminal-position = top
quick-terminal-screen = mouse
quick-terminal-autohide = true
quick-terminal-animation-duration = 0.15
keybind = global:ctrl+grave_accent=toggle_quick_terminalglobal 快捷键才能在其他应用获得焦点时工作。Quick Terminal 只保留应用运行期间的状态,Ghostty 完全退出后不会恢复这个窗口。配置 Fish
~/.config/fish/config.fish。PATH、Homebrew、direnv 和通用函数可以放在这里,Starship 与 zoxide 这类交互工具需要限制在交互式会话中初始化。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (fish)
if status is-interactive
if type -q starship
starship init fish | source
end
if type -q zoxide
zoxide init fish | source
end
endconfig.fish 也可能被非交互式 Fish 进程读取。会产生输出或修改交互界面的命令如果没有 status is-interactive 保护,可能影响 SSH、SCP、rsync 或自动化脚本。~/.config/fish/functions/。例如 nls.fish 和 lsd.fish 可以统一调用下面的命令。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (fish)
eza -lh --icons=auto $argv配置 Starship
~/.config/starship.toml。如果只需要目录、Git 状态和语言运行时,直接使用 Nerd Font Symbols preset 即可,不需要手写复杂的 Prompt 逻辑。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
starship preset nerd-font-symbols -o ~/.config/starship.toml使用 fzf 和 zoxide
fzf 可以从当前候选项中筛选内容。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
fzfz 接收目录名片段,zi 使用交互式候选列表。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
z <dir-fragment>
zi使用 eza、bat 和 Lazygit
--icons=auto 会在当前字体支持时显示文件图标。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
eza -lh --icons=auto-p 会隐藏额外边框,只保留文本和语法高亮。Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
bat -p <file>Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (shell)
lazygit配置代理与环境变量
Terminal Stack 配置指南,Ghostty、Fish 与常用命令行工具 (fish)
proxy on
proxy off
proxy statusproxy off,或者在单条命令中清理 HTTP_PROXY、HTTPS_PROXY 和 ALL_PROXY。限制启动配置的内容
config.fish 适合保存稳定的 PATH、Prompt 初始化、direnv hook 和通用函数。项目 token、API key 与一次性调试变量应放在项目本地的 .envrc、私密环境文件、密码管理器或 Secret Manager 中。