Skip to content

Ghostty 配置备份

约 1277 字大约 4 分钟

MacOS

2026-07-05

自用配置:Ghostty + zsh + antidote + starship 终端环境备份。


一、用 Homebrew 安装

安装完成后 brew list 应如下:

==> Formulae
antidote        starship

==> Casks
ghostty

1. 安装 Homebrew(如果还没有)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

2. 安装三件套

# Ghostty 终端(图形应用,用 cask 安装)
brew install --cask ghostty

# antidote —— zsh 插件管理器
brew install antidote

# starship —— 跨 shell 的提示符(prompt)
brew install starship

# Nerd Font 字体(Ghostty 字体 + starship 图标都依赖它,缺少会显示乱码方块)
# 任选一款 Nerd Font 即可,这里以 FiraCode 为例:
brew install --cask font-fira-code-nerd-font

提示:.zshrc 里已配置了 USTC 中科大镜像(HOMEBREW_* 环境变量), 首次安装时如果网络慢,可以先手动 export 这几个变量再执行 brew 命令。

3. 字体也可以手动下载安装

如果不用 brew 装字体,可以从 Nerd Fonts 官网手动下载,任选喜欢的一款 (以 FiraCode Nerd Font 为例):

  1. 打开 https://www.nerdfonts.com/font-downloads
  2. 选一款字体,点击 Download 下载 zip
  3. 解压后全选 .ttf 文件,双击用「字体册(Font Book)」安装
  4. 重启 Ghostty 后字体生效

如果选了别的字体,记得把 config.ghostty 里的 font-family 改成对应的字体名。 已安装的 Nerd Font 可以这样确认(以 FiraCode 为例):

system_profiler SPFontsDataType | grep -i "FiraCode Nerd"

二、配置文件位置

配置文件位置作用
.zshrc~/.zshrczsh 主配置
.zsh_plugins.txt~/.config/antidote/.zsh_plugins.txtantidote 插件列表
starship.toml~/.config/starship.tomlstarship 提示符主题
config.ghostty~/Library/Application Support/com.mitchellh.ghostty/config.ghosttyGhostty 终端配置

上表除 .zsh_plugins.txt 外均为各工具的默认位置。 .zsh_plugins.txt 的路径是自定义的,由 .zshrcantidote load 指定,两处需保持一致。

Ghostty 配置文件可在 Ghostty 中按 ⌘ + , 直接打开。


三、配置文件完整内容(自用配置)

1. ~/.zshrc

# antidote
source /opt/homebrew/opt/antidote/share/antidote/antidote.zsh
antidote load $HOME/.config/antidote/.zsh_plugins.txt


# my env
export MYENV="/Volumes/Data/Environment"
export MYDeveloperProject="/Volumes/Data/DeveloperProject"

# Homebrew
# export PATH=/opt/homebrew/bin/:$PATH
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.ustc.edu.cn/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.ustc.edu.cn/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles"
export HOMEBREW_API_DOMAIN="https://mirrors.ustc.edu.cn/homebrew-bottles/api"

# local
export PATH="$HOME/.local/bin:$PATH"

# go
export PATH="$PATH:$MYENV/Go/sdk/go1.25.11/bin"
export GOPATH="$MYENV/Go/path"
export PATH="$PATH:$GOPATH/bin"

# rust
export CARGO_HOME="$MYENV/rust/cargo"
export PATH="$MYENV/rust/cargo/bin:$PATH"
export RUSTUP_HOME="$MYENV/rust/rustup"

# miniconda
export PATH="$MYENV/miniconda/miniconda3/bin:$PATH"
export CONDARC="$MYENV/miniconda/.condarc"

# Java
export JAVA_HOME=$MYENV/Java/azul-21.0.11/Contents/Home
export PATH=$JAVA_HOME/bin:$PATH

# node
export PATH="$PATH:$MYENV/nodejs/node-v24.18.0-darwin-arm64/bin"
export NPM_CONFIG_CACHE="$MYENV/nodejs/npm-cache"

# adb
export PATH="$PATH:$MYENV/Android/platform-tools"


# DBngin
# export PATH=/Users/Shared/DBngin/redis/7.0.0/bin:$PATH


# starship
eval "$(starship init zsh)"

2. ~/.config/antidote/.zsh_plugins.txt

# 基础功能
zsh-users/zsh-syntax-highlighting  # 语法高亮
zsh-users/zsh-autosuggestions      # 命令建议
# zsh-users/zsh-history-substring-search  # 历史搜索

3. ~/.config/starship.toml

图标依赖 Nerd Font。

"$schema" = 'https://starship.rs/config-schema.json'

format = """
[](#9A348E)\
$os\
$username\
[](bg:#DA627D fg:#9A348E)\
$directory\
[](fg:#DA627D bg:#FCA17D)\
$git_branch\
$git_status\
[](fg:#FCA17D bg:#86BBD8)\
$c\
$elixir\
$elm\
$golang\
$gradle\
$haskell\
$java\
$julia\
$maven\
$nodejs\
$bun\
$nim\
$rust\
$scala\
[](fg:#86BBD8 bg:#06969A)\
$docker_context\
[](fg:#06969A bg:#33658A)\
$time\
[ ](fg:#33658A)\
"""

# Disable the blank line at the start of the prompt
# add_newline = false

# You can also replace your username with a neat symbol like   or disable this
# and use the os module below
[username]
show_always = true
style_user = "fg:#FFFFFF bg:#9A348E"
style_root = "fg:#FFFFFF bg:#9A348E"
format = '[$user ]($style)'
disabled = false

# An alternative to the username module which displays a symbol that
# represents the current operating system
[os]
style = "fg:#FFFFFF bg:#9A348E"
disabled = true # Disabled by default

[directory]
style = "fg:#FFFFFF bg:#DA627D"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"

# Here is how you can shorten some long paths by text replacement
# similar to mapped_locations in Oh My Posh:
[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = ""
"Music" = ""
"Pictures" = ""
# Keep in mind that the order matters. For example:
# "Important Documents" = " 󰈙 "
# will not be replaced, because "Documents" was already substituted before.
# So either put "Important Documents" before "Documents" or use the substituted version:
# "Important 󰈙 " = " 󰈙 "

[c]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[cpp]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[docker_context]
symbol = ""
style = "fg:#FFFFFF bg:#06969A"
format = '[ $symbol $context ]($style)'

[elixir]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[elm]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[git_branch]
symbol = ""
style = "fg:#2D2D2D bg:#FCA17D"
format = '[ $symbol $branch ]($style)'

[git_status]
style = "fg:#2D2D2D bg:#FCA17D"
format = '[$all_status$ahead_behind ]($style)'

[golang]
symbol = "󰟓 "
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[gradle]
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[haskell]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[java]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[julia]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[maven]
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[nodejs]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[bun]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[nim]
symbol = "󰆥 "
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[rust]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[scala]
symbol = ""
style = "fg:#2D2D2D bg:#86BBD8"
format = '[ $symbol ($version) ]($style)'

[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "fg:#FFFFFF bg:#33658A"
format = '[ ♥ $time ]($style)'

4. ~/Library/Application Support/com.mitchellh.ghostty/config.ghostty

# ── 字体 ──
font-family = FiraCode Nerd Font
# font-size = 14
# 粗体/斜体可单独指定
# font-family-bold = JetBrains Mono Bold
# 连字(ligatures)默认开启,想关闭:
# font-feature = -liga

# ── 主题与配色 ──
theme = Catppuccin Latte
# 支持亮暗自动切换:
# theme = light:catppuccin-latte,dark:catppuccin-mocha
# 查看所有内置主题:终端运行 `ghostty +list-themes`

# ── 窗口外观 ──
# background-opacity = 0.92
# background-blur-radius = 20        # macOS 毛玻璃效果
# window-padding-x = 10
# window-padding-y = 8
# macos-titlebar-style = tabs        # 标题栏样式: native / transparent / tabs / hidden

# ── 光标 ──
# cursor-style = block               # block / bar / underline
# cursor-style-blink = false

# ── 行为 ──
# scrollback-limit = 10000000        # 回滚缓冲区(字节)
# copy-on-select = clipboard         # 选中即复制
# confirm-close-surface = false      # 关闭窗口不弹确认
# window-save-state = always         # 重启恢复窗口

# ── Shell 集成(自动注入,一般无需配置)──
# shell-integration = detect
# shell-integration-features = cursor,sudo,title

# ── 快捷键(keybind)──
# keybind = cmd+d=new_split:right
# keybind = cmd+shift+d=new_split:down
# keybind = cmd+shift+enter=toggle_split_zoom
# keybind = cmd+k=clear_screen

# ── macOS 特有 ──
# macos-option-as-alt = true         # Option 作为 Alt 键(用 Emacs/tmux 常用)
# quick-terminal-position = top      # 下拉式快捷终端位置
# keybind = global:cmd+grave_accent=toggle_quick_terminal   # 全局呼出快捷终端