macOS 安装 Ghostty 终端完整教程:环境、依赖与美化配置

macOS 安装 Ghostty 终端完整教程:环境、依赖与美化配置

更新时间:2026-06-11

本机验证:Ghostty 1.3.1 stable,安装位置 /Applications/Ghostty.app

适用系统:macOS 13 Ventura 及以上,Apple Silicon 和 Intel Mac 都可用

Ghostty 是一个原生、高性能、配置简单的现代终端。官方 macOS 下载页显示,Ghostty 当前提供 universal binary,支持 Apple Silicon 和 Intel 机器,并要求 macOS 13+。官方安装文档也说明,macOS 预编译版本由 Ghostty 项目官方提供、签名并公证;Homebrew cask 是社区维护的安装方式,会重新打包官方 .dmg

参考链接:

一、安装前检查

先确认系统版本和芯片架构:

bash 复制代码
sw_vers
uname -m

要求:

  • macOS 13 Ventura 或更新版本。
  • arm64 表示 Apple Silicon,x86_64 表示 Intel。
  • 建议先安装 Xcode Command Line Tools,方便后续安装 Homebrew、字体和命令行工具。

安装 Command Line Tools:

bash 复制代码
xcode-select --install

如果已经安装过,可以用下面命令检查:

bash 复制代码
xcode-select -p

能输出类似 /Library/Developer/CommandLineTools 就说明可用。

二、安装 Homebrew

如果你的 Mac 已经安装 Homebrew,可以跳过本节。

安装命令:

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

Apple Silicon Mac 通常需要把 Homebrew 加入 PATH

bash 复制代码
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Intel Mac 通常是:

bash 复制代码
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"

检查:

bash 复制代码
brew --version
brew doctor

三、安装 Ghostty

推荐方式是 Homebrew:

bash 复制代码
brew install --cask ghostty

如果你不想用 Homebrew,也可以到官方页面下载安装:

  1. 打开 Ghostty Download
  2. 下载 macOS universal .dmg
  3. 打开 .dmg
  4. Ghostty.app 拖入 /Applications

安装后启动:

bash 复制代码
open -a Ghostty

验证版本:

bash 复制代码
/Applications/Ghostty.app/Contents/MacOS/ghostty --version

如果想在任意终端里直接运行 ghostty 命令,可以建立一个用户级软链接:

bash 复制代码
mkdir -p ~/.local/bin
ln -sf /Applications/Ghostty.app/Contents/MacOS/ghostty ~/.local/bin/ghostty
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
ghostty --version

四、安装字体环境

Ghostty 默认已经内置 JetBrains Mono,也内置 Nerd Font 支持;但如果你想获得更好看的中文、图标、Powerline 提示符,建议安装 Nerd Font。

本机 Ghostty 配置使用的是:

  • 主字体:Maple Mono NF CN
  • 图标补充字体:Symbols Nerd Font

用 Homebrew 安装:

bash 复制代码
brew install --cask font-maple-mono-nf-cn
brew install --cask font-symbols-only-nerd-font

Homebrew 页面:

安装完成后,建议重启 Ghostty。你也可以检查 Ghostty 能识别哪些字体:

bash 复制代码
ghostty +list-fonts

如果 ghostty 命令没有加入 PATH,使用完整路径:

bash 复制代码
/Applications/Ghostty.app/Contents/MacOS/ghostty +list-fonts

五、安装 Shell 美化工具链

本机 Shell 美化依赖以下工具:

  • starship:跨 Shell 的高颜值提示符。
  • zoxide:更智能的 cd
  • eza:更现代的 ls
  • bat:带语法高亮的 cat
  • fzf:模糊搜索。
  • ripgrep:高速文本搜索。
  • fd:更好用的 find
  • zsh-autosuggestions:Zsh 自动建议。
  • zsh-syntax-highlighting:Zsh 语法高亮。

一次安装:

bash 复制代码
brew install starship zoxide eza bat fzf ripgrep fd
brew install zsh-autosuggestions zsh-syntax-highlighting

Starship 官方文档也推荐先安装 Nerd Font,再在 Zsh 里加入:

bash 复制代码
eval "$(starship init zsh)"

参考:Starship 安装文档

六、配置 Zsh

编辑 ~/.zshrc

bash 复制代码
nano ~/.zshrc

推荐加入下面内容:

bash 复制代码
# Homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"

# Starship prompt
eval "$(starship init zsh)"

# Zoxide
eval "$(zoxide init zsh)"

# Zsh plugins
source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

# Better ls
alias ls="eza --icons --color=auto"
alias ll="eza -lha --icons"
alias la="eza -a --icons"

# Better cat
alias cat="bat"

# Clear
alias c="clear"

如果是 Intel Mac,把 /opt/homebrew 改成 /usr/local

应用配置:

bash 复制代码
source ~/.zshrc

注意:本机当前 ~/.zshrc 里有两处 eval "$(starship init zsh)",实际使用时保留一处即可,避免重复初始化。

七、配置 Starship

创建配置目录:

bash 复制代码
mkdir -p ~/.config
nano ~/.config/starship.toml

下面是本机使用的 Catppuccin 风格 Starship 配置,适合配合 Ghostty、Maple Mono NF CN 和 Nerd Font:

toml 复制代码
"$schema" = 'https://starship.rs/config-schema.json'
add_newline = false
format = """
[](red)\
$os\
$username\
[](bg:peach fg:red)\
$directory\
[](bg:yellow fg:peach)\
$git_branch\
$git_status\
[](fg:yellow bg:green)\
$c\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:green bg:sapphire)\
$conda\
[](fg:sapphire bg:lavender)\
$time\
[ ](fg:lavender)\
$cmd_duration\
$line_break\
$character"""

palette = 'catppuccin_mocha'

[os]
disabled = false
style = "bg:red fg:crust"

[os.symbols]
Macos = "󰀵"
Linux = "󰌽"
Windows = ""
Ubuntu = "󰕈"
Debian = "󰣚"
Arch = "󰣇"
Fedora = "󰣛"
Android = ""

[username]
show_always = true
style_user = "bg:red fg:crust"
style_root = "bg:red fg:crust"
format = '[ $user]($style)'

[directory]
style = "bg:peach fg:crust"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = ".../"

[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = "󰝚 "
"Pictures" = " "
"Developer" = "󰲋 "

[git_branch]
symbol = ""
style = "bg:yellow"
format = '[[ $symbol $branch ](fg:crust bg:yellow)]($style)'

[git_status]
style = "bg:yellow"
format = '[[($all_status$ahead_behind )](fg:crust bg:yellow)]($style)'

[nodejs]
symbol = ""
style = "bg:green"
format = '[[ $symbol( $version) ](fg:crust bg:green)]($style)'

[python]
symbol = ""
style = "bg:green"
format = '[[ $symbol( $version)(\(#$virtualenv\)) ](fg:crust bg:green)]($style)'

[time]
disabled = false
time_format = "%R"
style = "bg:lavender"
format = '[[  $time ](fg:crust bg:lavender)]($style)'

[line_break]
disabled = true

[character]
disabled = false
success_symbol = '[❯](bold fg:green)'
error_symbol = '[❯](bold fg:red)'
vimcmd_symbol = '[❮](bold fg:green)'

[cmd_duration]
show_milliseconds = true
format = " in $duration "
style = "bg:lavender"
disabled = false
show_notifications = true
min_time_to_notify = 45000

[palettes.catppuccin_mocha]
red = "#f38ba8"
peach = "#fab387"
yellow = "#f9e2af"
green = "#a6e3a1"
sapphire = "#74c7ec"
lavender = "#b4befe"
crust = "#11111b"

如果图标显示成方块,优先检查字体是否安装成功,以及 Ghostty 配置里的 font-family 是否指向 Nerd Font。

八、Ghostty 配置文件位置

Ghostty 官方文档说明,配置文件支持这些位置:

text 复制代码
~/.config/ghostty/config.ghostty
~/.config/ghostty/config
~/Library/Application Support/com.mitchellh.ghostty/config.ghostty
~/Library/Application Support/com.mitchellh.ghostty/config

macOS 专用路径会在 XDG 路径之后加载;如果多个文件里有冲突配置,后加载的值会覆盖前面的值。

建议 macOS 用户直接使用:

bash 复制代码
mkdir -p "$HOME/Library/Application Support/com.mitchellh.ghostty"
nano "$HOME/Library/Application Support/com.mitchellh.ghostty/config.ghostty"

Ghostty 配置语法很简单:

text 复制代码
key = value

修改后可在 Ghostty 里按:

text 复制代码
Cmd + Shift + ,

重新加载配置。官方默认也是 macOS 用 cmd+shift+, 重载配置。

九、本机 Ghostty 美化配置

下面是本机正在使用的 Ghostty 配置,重点效果:

  • 使用 Maple Mono NF CN,兼顾中文和 Nerd Font 图标。
  • 主题跟随系统明暗模式:亮色用 Catppuccin Latte,暗色用 Catppuccin Mocha。
  • 开启透明背景和毛玻璃模糊。
  • 标题栏透明。
  • 启用分屏、标签页、快速终端、命令跳转和常用快捷键。
  • 开启剪贴板粘贴保护。

配置文件路径:

text 复制代码
~/Library/Application Support/com.mitchellh.ghostty/config.ghostty

完整配置:

ini 复制代码
#====================== Ghostty 终极整合配置 ======================
# 适用:macOS + 开发工匠 + 毛玻璃 + 分屏 + 快速终端
# 字体:Nerd Font 专用 | 主题:自动明暗模式 | 快捷键:极简好记
# 重载配置:Cmd + Shift + ,
# super = ⌘ Command
# alt = ⌥ Option
# ctrl = ⌃ Control
# shift = ⇧ Shift
# ==================================================================

# --- Typography ---
font-family = "Maple Mono NF CN"
font-size = 12
adjust-cell-height = 2

# --- Theme and Colors ---
theme = "light:Catppuccin Latte,dark:Catppuccin Mocha"

# --- Window and Appearance ---
background-opacity = 0.85
background-blur-radius = 30
macos-titlebar-style = transparent
window-padding-x = 10
window-padding-y = 8
window-save-state = always
window-theme = auto

# --- Cursor ---
cursor-style = bar
cursor-style-blink = true
cursor-opacity = 0.8

# --- Mouse ---
mouse-hide-while-typing = true
copy-on-select = clipboard
scrollback-limit = 25000000

# --- Quick Terminal ---
quick-terminal-position = top
quick-terminal-screen = mouse
quick-terminal-autohide = true
quick-terminal-animation-duration = 0.15

# --- Security ---
clipboard-paste-protection = true
clipboard-paste-bracketed-safe = true

# --- Shell Integration ---
shell-integration = zsh

# --- Page Scroll ---
keybind = super+page_up=scroll_page_up
keybind = super+page_down=scroll_page_down
keybind = super+home=scroll_to_top
keybind = super+end=scroll_to_bottom

# --- Split ---
keybind = super+ctrl+equal=equalize_splits
keybind = super+d=new_split:right
keybind = super+shift+d=new_split:down
keybind = super+shift+enter=toggle_split_zoom
keybind = super+alt+up=goto_split:up
keybind = super+alt+down=goto_split:down
keybind = super+alt+left=goto_split:left
keybind = super+alt+right=goto_split:right
keybind = super+left_bracket=goto_split:previous
keybind = super+right_bracket=goto_split:next
keybind = super+ctrl+up=resize_split:up,10
keybind = super+ctrl+down=resize_split:down,10
keybind = super+ctrl+left=resize_split:left,10
keybind = super+ctrl+right=resize_split:right,10

# --- Tabs ---
keybind = super+t=new_tab
keybind = super+shift+left_bracket=previous_tab
keybind = super+shift+right_bracket=next_tab
keybind = ctrl+tab=next_tab
keybind = ctrl+shift+tab=previous_tab
keybind = super+physical:one=goto_tab:1
keybind = super+physical:two=goto_tab:2
keybind = super+physical:three=goto_tab:3
keybind = super+physical:four=goto_tab:4
keybind = super+physical:five=goto_tab:5
keybind = super+physical:six=goto_tab:6
keybind = super+physical:seven=goto_tab:7
keybind = super+physical:eight=goto_tab:8
keybind = super+physical:nine=last_tab

# --- Window ---
keybind = super+n=new_window
keybind = super+w=close_surface
keybind = super+alt+w=close_tab
keybind = super+shift+w=close_window
keybind = super+alt+shift+w=close_all_windows
keybind = super+q=quit

# --- Font Size ---
keybind = super+equal=increase_font_size:1
keybind = super+plus=increase_font_size:1
keybind = super+minus=decrease_font_size:1
keybind = super+zero=reset_font_size

# --- Prompt Jump ---
keybind = super+up=jump_to_prompt:-1
keybind = super+shift+up=jump_to_prompt:-1
keybind = super+down=jump_to_prompt:1
keybind = super+shift+down=jump_to_prompt:1

# --- Selection ---
keybind = shift+up=adjust_selection:up
keybind = shift+down=adjust_selection:down
keybind = shift+left=adjust_selection:left
keybind = shift+right=adjust_selection:right
keybind = shift+page_up=adjust_selection:page_up
keybind = shift+page_down=adjust_selection:page_down
keybind = shift+home=adjust_selection:home
keybind = shift+end=adjust_selection:end

# --- Clipboard ---
keybind = super+a=select_all
keybind = super+c=copy_to_clipboard
keybind = super+v=paste_from_clipboard
keybind = super+shift+v=paste_from_selection

# --- Config / Debug / Fullscreen ---
keybind = super+comma=open_config
keybind = super+shift+comma=reload_config
keybind = super+alt+i=inspector:toggle
keybind = super+enter=toggle_fullscreen
keybind = super+ctrl+f=toggle_fullscreen

# --- Terminal Editing ---
keybind = super+k=clear_screen
keybind = alt+left=esc:b
keybind = alt+right=esc:f
keybind = super+left=text:\x01
keybind = super+right=text:\x05
keybind = super+backspace=text:\x15

# --- Export Screen ---
keybind = super+alt+shift+j=write_screen_file:open
keybind = super+shift+j=write_screen_file:paste

十、推荐快捷键说明

功能 快捷键
打开配置文件 Cmd + ,
重载配置 Cmd + Shift + ,
新建标签页 Cmd + T
新建窗口 Cmd + N
关闭当前面板 Cmd + W
左右分屏 Cmd + D
上下分屏 Cmd + Shift + D
放大当前分屏 Cmd + Shift + Enter
切换全屏 Cmd + Enter
清屏 Cmd + K
放大字体 Cmd + =
缩小字体 Cmd + -
重置字体大小 Cmd + 0
跳到上一个命令提示符 Cmd + Up
跳到下一个命令提示符 Cmd + Down

十一、常见问题

1. 图标显示成方块

原因通常是字体没装好,或者 Ghostty 没有使用 Nerd Font。

处理:

bash 复制代码
brew install --cask font-maple-mono-nf-cn
brew install --cask font-symbols-only-nerd-font

然后确认配置:

ini 复制代码
font-family = "Maple Mono NF CN"

重启 Ghostty。

2. 透明和毛玻璃没有效果

确认配置:

ini 复制代码
background-opacity = 0.85
background-blur-radius = 30
macos-titlebar-style = transparent

如果仍然没有效果,先重启 Ghostty,而不是只 reload 配置。部分窗口相关配置可能需要新窗口或重启后才完整生效。

3. Starship 提示符不显示

检查 ~/.zshrc 是否包含:

bash 复制代码
eval "$(starship init zsh)"

检查 Starship 是否安装:

bash 复制代码
starship --version

4. ghostty 命令不存在

如果 Ghostty 可以从应用程序启动,但命令行没有 ghostty,建立软链接:

bash 复制代码
mkdir -p ~/.local/bin
ln -sf /Applications/Ghostty.app/Contents/MacOS/ghostty ~/.local/bin/ghostty
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

5. Homebrew 安装失败

先更新 Homebrew:

bash 复制代码
brew update
brew doctor

如果网络不稳定,可以改用官方 .dmg 安装 Ghostty。

十二、完整安装命令汇总

新机器可以按这个顺序执行:

bash 复制代码
# 1. Command Line Tools
xcode-select --install

# 2. Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"

# 3. Ghostty
brew install --cask ghostty

# 4. Fonts
brew install --cask font-maple-mono-nf-cn
brew install --cask font-symbols-only-nerd-font

# 5. Shell tools
brew install starship zoxide eza bat fzf ripgrep fd
brew install zsh-autosuggestions zsh-syntax-highlighting

# 6. Optional CLI shortcut
mkdir -p ~/.local/bin
ln -sf /Applications/Ghostty.app/Contents/MacOS/ghostty ~/.local/bin/ghostty

然后分别配置:

text 复制代码
~/.zshrc
~/.config/starship.toml
~/Library/Application Support/com.mitchellh.ghostty/config.ghostty

最后重启 Ghostty。

相关推荐
麦麦麦当劳大王3 小时前
OpenClaw安装部署(Windows/Linux/MacOS)
linux·windows·macos
会Tk矩阵群控的小木3 小时前
独立站tk矩阵系统站外引流实战:多账号管理+风控+数据分析代码实现
运维·macos·自动化·个人开发·tk矩阵
console.log('npc')3 小时前
FigmaEX 汉化,免费使用,下载与安装指南(Windows/Mac)
windows·macos·ui·figma
云水-禅心3 小时前
解决MacOS 安装Python之后默认版本指向不正确问题
开发语言·python·macos
Rudon滨海渔村4 小时前
macOS文件夹创建桌面快捷方式 - 发送到桌面快捷方式
macos
10086love1001015 小时前
Macos安装codex
macos
ryanuo721 小时前
Mac(M芯片)上进行嵌入式开发遇到的问题
嵌入式硬件·macos·开发板
不爱记笔记1 天前
苹果WWDC 2026全解析:Apple Intelligence+ 性能提升数据一览
macos·ios·wwdc
小小程序员mono1 天前
WWDC 2026 之后,M5 桌面 Mac 上市时间预测
macos·ios·wwdc