編者按: Ghostty 在 2024 年底由 HashiCorp 創辦人 Mitchell Hashimoto 開源後迅速走紅,憑藉 Zig 語言編寫 + GPU 硬體加速渲染,在效能表現上遠超傳統終端模擬器。2025 年正式發佈 1.0 穩定版後,它已成為 macOS 和 Linux 開發者社群最熱門的新終端選擇。本文帶你從零上手,全面掌握 Ghostty 的安裝、設定與進階用法。


一、Ghostty 是什麼?為什麼值得關注?

1.1 核心特性

Ghostty 是一個跨平台、GPU 加速、原生 UI的終端模擬器,其設計哲學可以用三個詞概括:

特性 說明
GPU 加速 使用 OpenGL/Metal 渲染,幀率遠超 CPU 渲染的終端
原生 UI macOS 上使用 AppKit,Linux 上使用 GTK4,而非 Electron/Web 技術棧
Zig 編寫 底層用 Zig 語言,記憶體安全、效能極致、編譯產物精簡

1.2 與主流終端的對比

終端 語言 渲染方式 平台 開源
Ghostty Zig GPU (OpenGL/Metal) macOS, Linux ✅ MIT
iTerm2 Objective-C CPU macOS
Alacritty Rust GPU (OpenGL) macOS, Linux, Windows ✅ Apache
Kitty C/Python GPU (OpenGL) macOS, Linux ✅ GPL
Tabby TypeScript Electron/Canvas 全平台 ✅ MIT

Ghostty 的核心優勢在於:用 Zig 保證了極致的啟動速度和記憶體佔用,同時用原生 UI 框架而非跨平台框架,確保與作業系統的深度整合。

1.3 誰適合用 Ghostty?

  • 追求啟動速度和渲染流暢度的開發者
  • 厭倦了 Electron 終端(如 Tabby)吃記憶體的使用者
  • macOS 上想找一個現代、輕量、可自訂的終端替代 iTerm2
  • Linux 上需要GTK4 原生整合的終端模擬器

二、安裝 Ghostty

2.1 macOS 安裝

方式一:Homebrew(推薦)

brew install --cask ghostty

安裝完成後,在 Launchpad 或 Spotlight 中搜尋 "Ghostty" 即可啟動。

方式二:手動下載

前往 Ghostty GitHub Releases 下載 .dmg 檔案,拖入 /Applications 目錄。

2.2 Linux 安裝

Ubuntu / Debian:

# 新增官方 APT 儲存庫
curl -fsSL https://ghostty.org/install.sh | sh

Arch Linux:

# 使用 AUR
yay -S ghostty
# 或使用官方套件
pacman -S ghostty

Fedora / RHEL:

# 透過 COPR 儲存庫安裝
sudo dnf copr enable ghostty/ghostty
sudo dnf install ghostty

2.3 從原始碼編譯

如果你想體驗最新特性或貢獻程式碼,可以從原始碼編譯:

# 複製儲存庫
git clone https://github.com/ghostty-org/ghostty.git
cd ghostty

# 安裝 Zig 編譯器(需要 0.13+)
# macOS
brew install zig
# Linux
# 前往 https://ziglang.org/download/ 下載對應版本

# 編譯
zig build -Doptimize=ReleaseSafe

編譯產物位於 zig-out/bin/ghostty

2.4 驗證安裝

ghostty --version
# 輸出類似:ghostty 1.0.3 (2026-xx-xx)

三、快速上手

3.1 首次啟動

首次啟動 Ghostty,你會看到一個簡潔乾淨的終端視窗,預設使用系統字型和配色。Ghostty 的預設體驗已經很好,但真正的強大之處在於設定。

3.2 設定檔

Ghostty 使用簡潔的 key-value 設定檔,位於:

# macOS
~/.config/ghostty/config

# Linux
~/.config/ghostty/config

如果檔案不存在,手動建立:

mkdir -p ~/.config/ghostty
touch ~/.config/ghostty/config

3.3 最小可用設定

下面是一個入門級設定範例,涵蓋了最常用的設定:

# ~/.config/ghostty/config

# 字型設定
font-family = "JetBrains Mono"
font-size = 14

# 視窗設定
window-padding-x = 10
window-padding-y = 10
window-padding-balance = true

# 游標樣式
cursor-style = bar
cursor-color = "#58ff58"

# Shell(預設使用系統預設 shell)
# shell = /bin/zsh

四、主題與配色

4.1 內建主題

Ghostty 支援 darklight 兩種基本主題,但真正的強大之處在於自訂調色板:

# 在 config 檔案中切換
theme = "dark"
# 或
theme = "light"

4.2 自訂配色方案

Ghostty 支援完整的 16 色調色板自訂,相容所有主流終端主題:

# ~/.config/ghostty/config

# 前景色和背景色
foreground = "#cdd6f4"
background = "#1e1e2e"

# 16 色調色板(Catppuccin Mocha 範例)
palette = "0=#45475a;1=#f38ba8;2=#a6e3a1;3=#f9e2af;4=#89b4fa;5=#f5c2e7;6=#94e2d5;7=#bac2de;8=#585b70;9=#f38ba8;10=#a6e3a1;11=#f9e2af;12=#89b4fa;13=#f5c2e7;14=#94e2d5;15=#a6adc8"

4.3 熱門主題一鍵設定

Catppuccin Mocha(推薦):

foreground = "#cdd6f4"
background = "#1e1e2e"
palette = "0=#45475a;1=#f38ba8;2=#a6e3a1;3=#f9e2af;4=#89b4fa;5=#f5c2e7;6=#94e2d5;7=#bac2de;8=#585b70;9=#f38ba8;10=#a6e3a1;11=#f9e2af;12=#89b4fa;13=#f5c2e7;14=#94e2d5;15=#a6adc8"

Tokyo Night:

background = "#1a1b26"
foreground = "#a9b1d6"
palette = "0=#32344a;1=#f7768e;2=#9ece6a;3=#e0af68;4=#7aa2f7;5=#bb9af7;6=#7dcfff;7=#a9b1d6;8=#444b6a;9=#f7768e;10=#9ece6a;11=#e0af68;12=#7aa2f7;13=#bb9af7;14=#7dcfff;15=#c0caf5"

Nord:

background = "#2e3440"
foreground = "#d8dee9"
palette = "0=#3b4252;1=#bf616a;2=#a3be8c;3=#ebcb8b;4=#81a1c1;5=#b48ead;6=#88c0d0;7=#e5e9f0;8=#4c566a;9=#bf616a;10=#a3be8c;11=#ebcb8b;12=#81a1c1;13=#b48ead;14=#8fbcbb;15=#eceff4"

Gruvbox Dark:

background = "#282828"
foreground = "#ebdbb2"
palette = "0=#282828;1=#cc241d;2=#98971a;3=#d79921;4=#458588;5=#b16286;6=#689d6a;7=#a89984;8=#928374;9=#fb4934;10=#b8bb26;11=#fabd2f;12=#83a598;13=#d3869b;14=#8ec07c;15=#ebdbb2"

五、分割畫面與多視窗

5.1 分割畫面快捷鍵

Ghostty 內建了強大的分割畫面功能,無需 tmux 也能高效管理多個終端:

操作 macOS 快捷鍵 Linux 快捷鍵
左右分割 Cmd + \ Ctrl + Shift + \
上下分割 Cmd + Enter Ctrl + Shift + Enter
切換 pane 焦點 Cmd + Option + 方向鍵 Ctrl + Shift + 方向鍵
關閉 pane Cmd + Shift + W Ctrl + Shift + W

5.2 Tab 管理

操作 快捷鍵
新建分頁 Cmd + T / Ctrl + Shift + T
關閉分頁 Cmd + W / Ctrl + Shift + W
切換分頁 Cmd + { / Cmd + }
跳轉第 N 個分頁 Cmd + 1~9

5.3 預設視窗設定

# 視窗大小
window-width = 1200
window-height = 800

# 視窗位置
window-position-x = 100
window-position-y = 50

# 啟動時最大化
# window-maximize = true

六、進階設定

6.1 自訂鍵盤快捷鍵

Ghostty 的快捷鍵系統非常靈活,格式為 key = 修飾鍵+鍵 \ 動作

# ~/.config/ghostty/config

# 自訂分頁切換
key = cmd+1 \ tab:activate:1
key = cmd+2 \ tab:activate:2
key = cmd+3 \ tab:activate:3

# 自訂分割畫面快捷鍵
key = cmd+shift+v \ split:right
key = cmd+shift+h \ split:down

# 一鍵新建視窗並執行指令
key = cmd+shift+n \ spawn:window

6.2 滑鼠支援

Ghostty 完整支援 SGR 滑鼠事件協定,以下場景開箱即用:

  • Vim/Neovim — 滑鼠點擊跳轉、視覺化選擇
  • tmux — 滑鼠模式選擇視窗和 pane
  • htop / ranger / fzf — TUI 工具的滑鼠互動
# 滑鼠報告(預設開啟)
mouse-report = true

6.3 環境變數與 Shell 整合

# 啟動目錄
cwd = ~/Projects

# 環境變數
env = TERM=xterm-256color
env = LANG=zh_CN.UTF-8

# 自訂視窗標題
title = "Ghostty — {cwd}"

6.4 透明度與模糊效果(macOS)

# 背景透明度
background-opacity = 0.95

# macOS 毛玻璃效果
macos-titlebar-blur = true
macos-window-blur = true

6.5 游標與捲動

# 游標樣式:block(方塊), beam(直線), underline(底線)
cursor-style = bar

# 游標閃爍
cursor-blink = true

# 捲動行數
scrollback-limit = 20000

# 滑鼠滾輪速度
scroll-multiplier = 3

七、實戰場景

7.1 Ghostty + Neovim 完美搭配

Ghostty 的 GPU 渲染和完整的鍵盤協定支援,使其成為 Neovim 的理想終端:

# ~/.config/ghostty/config

# 啟用 kitty 鍵盤協定(增強鍵盤支援,區分 Ctrl+ 組合鍵)
kitty-keyboard = true

# 確保真彩色
env = TERM=xterm-256color

Ghostty 對 Neovim 的完整支援包括: - ✅ 真彩色(24-bit color) - ✅ italic / bold / underline / strikethrough - ✅ kitty 鍵盤協定(正確區分 Ctrl+iTab) - ✅ OSC 52 剪貼簿整合 - ✅ 快速渲染,打字零延遲

7.2 Ghostty + tmux 組合

對於重度 tmux 使用者,Ghostty 能無縫配合:

# Ghostty config
term = xterm-ghostty

~/.tmux.conf 中:

# 啟用滑鼠
set -g mouse on

# 真彩色
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-ghostty:Tc"

Ghostty 從 1.0 版本開始支援 TERM=xterm-ghostty,tmux 3.3+ 可正確識別。

7.3 多視窗工作流範例

假設你是全端開發者,可以這樣設定 Ghostty 的多視窗工作流:

# 一鍵啟動前端開發環境
key = cmd+shift+f \ spawn:window npm run dev

# 一鍵啟動後端服務
key = cmd+shift+b \ spawn:window make run

# 一鍵開啟日誌監控
key = cmd+shift+l \ spawn:window tail -f logs/app.log

八、效能對比

以下是 Ghostty 與主流終端模擬器的效能對比(基於社群基準測試):

指標 Ghostty Alacritty Kitty iTerm2
冷啟動 ~30ms ~20ms ~40ms ~150ms
記憶體佔用 ~25MB ~15MB ~35MB ~200MB
渲染方式 GPU GPU GPU CPU
大檔案捲動 ⚡ 流暢 ⚡ 流暢 ⚡ 流暢 🐢 卡頓
Tab/分割 ✅ 內建 ❌ 需 tmux ✅ 內建 ✅ 內建
設定語言 INI TOML conf plist

Ghostty 的記憶體佔用遠低於 iTerm2,啟動速度與 Alacritty 相當,同時內建分割畫面功能,不需要額外依賴 tmux。


九、常見問題

Q1: Ghostty 支援 Windows 嗎?

目前 Ghostty 官方支援 macOSLinux。Windows 支援已在路線圖,但尚未正式發佈。Windows 使用者可以使用 WSL2 中的 Linux 版 Ghostty。

Q2: 如何匯入 iTerm2 的配色方案?

iTerm2 使用 .itermcolors XML 格式,需要手動轉換為 Ghostty 的 palette 格式。可以使用線上工具 iTerm to Ghostty 進行轉換。

Q3: Ghostty 的設定檔支援熱重載嗎?

是的!修改 ~/.config/ghostty/config 後,Ghostty 會自動偵測並套用變更,無需重新啟動。這是相比很多終端的一大優勢。

Q4: 可以用 Ghostty 替代 iTerm2 嗎?

對大多數開發者來說完全可以。Ghostty 涵蓋了 iTerm2 的核心功能: - ✅ 分割畫面、分頁、搜尋 - ✅ 自訂配色、字型 - ✅ 透明度、模糊效果 - ✅ 快捷鍵自訂 - ⚠️ 缺少:iTerm2 的 Shell Integration(Ghostty 有自己的實作)、Instant Replay、Broadcast Input


十、總結

Ghostty 憑藉 Zig 語言 + GPU 加速 + 原生 UI 三件套,在終端模擬器這個「老賽道」中殺出了一條新路。它不是功能最多的終端,但絕對是最快、最輕量、設定最優雅的終端之一。

推薦理由: - 🚀 GPU 加速渲染,打字零延遲 - 🎨 豐富的主題支援,熱重載設定 - 🖥️ 內建分割畫面,告別 tmux 依賴 - 🐧 macOS + Linux 雙平台原生支援 - 🔧 設定簡潔,學習成本低

如果你正在尋找一個快、美、穩的終端模擬器,Ghostty 值得列入你的首選清單。


相關連結: - Ghostty 官網 - Ghostty GitHub - Ghostty 文件 - Ghostty 設定參考