Ghostty + Fish + Starship 终端美化方案
这三个工具是什么?
Ghostty — 终端模拟器
Ghostty 是由 HashiCorp 创始人 Mitchell Hashimoto 开发的现代化终端模拟器。它是你看到的那个”窗口”,负责显示所有终端内容。
特点:
- 原生 macOS 应用,使用 Metal 渲染,速度快
- 支持 GPU 加速
- 支持标签页、分屏
- 配置简单,纯文本配置文件
- 支持图片显示(Kitty 图片协议)
类比: 如果终端是一辆车,Ghostty 就是车身和挡风玻璃——你看到的一切界面都是它提供的。
Fish — Shell(命令行解释器)
Fish(Friendly Interactive Shell)是一个现代化的 shell,替代默认的 zsh/bash。它是处理你输入的命令的那个程序。
特点:
- 开箱即用的语法高亮(输入命令时自动变色)
- 自动补全建议(灰色提示,按右箭头接受)
- 无需额外配置就有很好体验
- 基于 POSIX 但不完全兼容 bash 语法
类比: Fish 是发动机——你输入什么命令、命令怎么执行,都是它在处理。
Starship — 命令行提示符
Starship 是一个跨 shell 的提示符(prompt)美化工具。它显示在你输入命令之前的那一行,提供 git 分支、目录、语言版本等信息。
特点:
- 显示 git 状态(分支、修改数)
- 显示当前目录
- 显示 Node.js/Python/Go 等语言版本
- 支持自定义模块
- 跨 shell 通用(zsh、fish、bash 都能用)
类比: Starship 是仪表盘——它告诉你当前的状态信息(在哪个目录、git 什么分支、用的什么语言版本)。
它们怎么配合
┌─────────────────────────────────────────────┐│ Ghostty(终端窗口) ││ ┌─────────────────────────────────────────┐ ││ │ Starship 提示符 │ ││ │ ~/project on main via 🐹 v1.21 │ ││ │ │ ││ │ Fish 处理命令 │ ││ │ ❯ git status │ ││ │ ❯ npm run dev │ ││ └─────────────────────────────────────────┘ │└─────────────────────────────────────────────┘- Ghostty 提供窗口和渲染
- Fish 在窗口里运行,处理你的命令
- Starship 被 Fish 加载,美化提示符
安装过程
1. 安装 Ghostty
# 方式一:官网下载# 访问 https://ghostty.org 下载 macOS 版本
# 方式二:Homebrew(如果有的话)brew install --cask ghostty安装后打开 Ghostty 即可使用。
2. 安装 Nerd Font(重要)
Starship 的图标(如 git 分支的 、Node.js 的 )需要 Nerd Font 才能正确显示。推荐安装 JetBrains Mono Nerd Font:
brew install --cask font-jetbrains-mono-nerd-font安装完成后需要在 Ghostty 配置中指定使用该字体(见下方配置部分)。
2. 安装 Fish
brew install fish安装完成后,可以将 Fish 设为默认 shell:
# 将 fish 加入允许的 shell 列表echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells
# 设为默认 shellchsh -s /opt/homebrew/bin/fish3. 安装 Starship
brew install starship配置 shell 集成:
zsh(~/.zshrc):
echo 'eval "$(starship init zsh)"' >> ~/.zshrcfish(~/.config/fish/config.fish):
mkdir -p ~/.config/fishecho 'starship init fish | source' >> ~/.config/fish/config.fish配置
Ghostty 配置
配置文件位置:~/.config/ghostty/config
# 创建配置目录mkdir -p ~/.config/ghostty
# 写入配置cat > ~/.config/ghostty/config << 'EOF'# === 字体 ===font-family = "JetBrainsMono Nerd Font"font-size = 14font-thicken = true
# === 主题 ===theme = catppuccin-macchiato
# === 窗口 ===window-padding-x = 10window-padding-y = 6background-opacity = 0.92background-blur-radius = 20window-decoration = automacos-titlebar-style = transparent
# === Shell ===command = /opt/homebrew/bin/fish
# === 光标 ===cursor-style = blockcursor-style-blink = true
# === 滚动 ===scrollback-limit = 10000
# === 鼠标 ===copy-on-select = truemouse-hide-while-typing = true
# === 快捷键 ===# 新建标签页keybind = super+t=new_tab# 关闭标签页keybind = super+w=close_surface# 水平分屏keybind = super+d=new_split:right# 垂直分屏keybind = super+shift+d=new_split:down# 切换分屏keybind = super+alt+left=goto_split:leftkeybind = super+alt+right=goto_split:rightkeybind = super+alt+up=goto_split:upkeybind = super+alt+down=goto_split:down# 全屏keybind = super+enter=toggle_fullscreen# 增大/减小字号keybind = super+equal=increase_font_size:1keybind = super+minus=decrease_font_size:1keybind = super+zero=reset_font_sizeEOF配置说明:
font-family = "JetBrainsMono Nerd Font"— 使用 Nerd Font 版本以支持图标command = /opt/homebrew/bin/fish— 默认使用 Fish shellbackground-opacity = 0.92— 轻微透明效果background-blur-radius = 20— 背景模糊(毛玻璃效果)macos-titlebar-style = transparent— 透明标题栏
Starship 配置
配置文件位置:~/.config/starship.toml
mkdir -p ~/.config
cat > ~/.config/starship.toml << 'EOF'# 提示符格式format = """$username\$hostname\$directory\$git_branch\$git_status\$nodejs\$python\$golang\$rust\$cmd_duration\$line_break\$character"""
# 字符模块(提示符符号)[character]success_symbol = "[❯](bold green)"error_symbol = "[❯](bold red)"
# 目录[directory]truncation_length = 3style = "bold cyan"
# Git[git_branch]symbol = " "style = "bold purple"
[git_status]style = "bold red"
# 命令耗时[cmd_duration]min_time = 2000format = "took [$duration]($style) "EOFFish 配置
Fish 的配置在 ~/.config/fish/config.fish,一般不需要太多配置,开箱即用。如果需要自定义:
# 设置 greeting(启动时的欢迎语)set -g fish_greeting ""
# 常用缩写abbr -a gs git statusabbr -a gc git commitabbr -a gp git pushabbr -a ll ls -la使用技巧
Ghostty 常用快捷键
| 快捷键 | 功能 |
|---|---|
Cmd + T | 新建标签页 |
Cmd + D | 水平分屏 |
Cmd + Shift + D | 垂直分屏 |
Cmd + Enter | 全屏切换 |
Cmd + 数字 | 切换到第 N 个标签页 |
Fish 常用功能
- 自动补全: 输入命令时按
Tab触发补全 - 建议接受: 灰色建议文字按
→(右箭头)接受 - 语法高亮: 有效命令绿色,无效命令红色
Starship 信息解读
~/project on main via 🐹 v1.21 [!] is 📦 v1.0.0~/project— 当前目录on main— git 分支via 🐹 v1.21— Go 版本[!]— 有未提交的修改is 📦 v1.0.0— 项目版本
版本信息
本次安装的版本:
- Ghostty 1.1.3
- Fish 4.0.2
- Starship 1.23.0
- JetBrains Mono Nerd Font 3.4.0
参考链接
- Ghostty 官网:https://ghostty.org
- Fish 官网:https://fishshell.com
- Starship 官网:https://starship.rs
如果这篇文章对你有帮助,欢迎分享给更多人!
部分信息可能已经过时





