Skip to content

Instantly share code, notes, and snippets.

@lltx
Created March 23, 2026 01:07
Show Gist options
  • Select an option

  • Save lltx/a61f98fdb761c9af7c5fd6cbfe963842 to your computer and use it in GitHub Desktop.

Select an option

Save lltx/a61f98fdb761c9af7c5fd6cbfe963842 to your computer and use it in GitHub Desktop.
🚀 现代化终端配置指南 - Ghostty + Zoxide + Yazi + Oh-My-Zsh

🚀 现代化终端配置指南

Ghostty + Zoxide + Yazi + Oh-My-Zsh 完整配置

📦 工具列表

  • Ghostty - 现代化 GPU 加速终端模拟器
  • Zoxide - 智能目录跳转工具(cd 的智能替代)
  • Yazi - 快速终端文件管理器
  • Oh-My-Zsh - Zsh 配置框架

🎨 Ghostty 配置

位置: ~/.config/ghostty/config

# ============================================
# Ghostty Terminal - Complete Configuration
# ============================================

# --- Typography ---
font-family = "Maple Mono NF CN"
font-size = 15
font-thicken = true
adjust-cell-height = 6

# --- Theme and Colors ---
theme = Kanagawa Wave

# --- Window and Appearance ---
background-opacity = 1
macos-titlebar-style = transparent
window-padding-x = 14
window-padding-y = 10
window-save-state = never
window-width = 80
window-height = 24
window-theme = auto

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

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

# --- Quick Terminal (Quake-style dropdown) ---
quick-terminal-position = top
quick-terminal-screen = mouse
quick-terminal-autohide = true
quick-terminal-animation-duration = 0.15

# --- Close behavior ---
confirm-close-surface = false

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

# --- Shell Integration ---
shell-integration = detect
shell-integration-features = cursor,sudo,no-title,ssh-env,ssh-terminfo,path

# --- Keybindings ---
# Tabs
keybind = cmd+t=new_tab
keybind = cmd+shift+left=previous_tab
keybind = cmd+shift+right=next_tab
keybind = cmd+w=close_surface

# Splits
keybind = cmd+d=new_split:right
keybind = cmd+shift+d=new_split:down
keybind = cmd+alt+left=goto_split:left
keybind = cmd+alt+right=goto_split:right
keybind = cmd+alt+up=goto_split:top
keybind = cmd+alt+down=goto_split:bottom

# Font size
keybind = cmd+plus=increase_font_size:1
keybind = cmd+minus=decrease_font_size:1
keybind = cmd+zero=reset_font_size

# Quick terminal global hotkey
keybind = global:ctrl+grave_accent=toggle_quick_terminal

# Splits management
keybind = cmd+shift+e=equalize_splits
keybind = cmd+shift+f=toggle_split_zoom

# Reload config
keybind = cmd+shift+comma=reload_config

# --- Performance ---
scrollback-limit = 25000000

📂 Yazi 文件管理器配置

主配置文件

位置: ~/.config/yazi/yazi.toml

[mgr]
ratio = [1, 2, 5]
sort_by = "natural"
sort_sensitive = false
sort_reverse = false
sort_dir_first = true
linemode = "size"
show_hidden = false
show_symlink = true
scrolloff = 5
mouse_events = ["click", "scroll"]
title_format = "Yazi: {cwd}"

[preview]
max_width = 600
max_height = 900
image_filter = "lanczos3"
image_quality = 75

[opener]
edit = [
  { run = 'code %s', desc = "VSCode", for = "unix" },
]
open = [
  { run = 'open %s', desc = "Open", for = "macos" },
]
reveal = [
  { run = 'open -R %1', desc = "Reveal in Finder", for = "macos" },
]

[open]
prepend_rules = [
  { mime = "text/*", use = ["edit", "open", "reveal"] },
  { mime = "application/json", use = ["edit", "open", "reveal"] },
  { mime = "*/javascript", use = ["edit", "open", "reveal"] },
  { mime = "*/typescript", use = ["edit", "open", "reveal"] },
  { mime = "*/x-yaml", use = ["edit", "open", "reveal"] },
]

[tasks]
micro_workers = 10
macro_workers = 25
bizarre_retry = 5

[plugin]
prepend_fetchers = [
  { id = "git", name = "*", run = "git", prio = "normal" },
]

快捷键配置

位置: ~/.config/yazi/keymap.toml

[[manager.prepend_keymap]]
on = ["g", "h"]
run = "cd ~"
desc = "Go to home directory"

[[manager.prepend_keymap]]
on = ["g", "c"]
run = "cd ~/.config"
desc = "Go to config directory"

[[manager.prepend_keymap]]
on = ["g", "d"]
run = "cd ~/Downloads"
desc = "Go to downloads"

[[manager.prepend_keymap]]
on = ["g", "w"]
run = "cd ~/work"
desc = "Go to work directory"

[[manager.prepend_keymap]]
on = ["g", "D"]
run = "cd ~/Desktop"
desc = "Go to desktop"

[[manager.prepend_keymap]]
on = ["g", "t"]
run = "cd /tmp"
desc = "Go to tmp"

主题配置

位置: ~/.config/yazi/theme.toml

# Tokyo Night inspired theme - works well with most terminal color schemes

[mode]
normal_main = { fg = "black", bg = "blue", bold = true }
normal_alt = { fg = "blue", bg = "reset", bold = true }
select_main = { fg = "black", bg = "green", bold = true }
select_alt = { fg = "green", bg = "reset", bold = true }
unset_main = { fg = "black", bg = "red", bold = true }
unset_alt = { fg = "red", bg = "reset", bold = true }

[status]
sep_left = { open = "", close = "" }
sep_right = { open = "", close = "" }
overall = { fg = "reset", bg = "reset" }

[filetype]
rules = [
  # Media
  { mime = "image/*", fg = "magenta" },
  { mime = "video/*", fg = "yellow" },
  { mime = "audio/*", fg = "yellow" },

  # Archives
  { mime = "application/zip", fg = "red" },
  { mime = "application/gzip", fg = "red" },
  { mime = "application/x-tar", fg = "red" },
  { mime = "application/x-bzip2", fg = "red" },
  { mime = "application/x-7z-compressed", fg = "red" },
  { mime = "application/x-rar", fg = "red" },
  { mime = "application/x-xz", fg = "red" },

  # Documents
  { mime = "application/pdf", fg = "cyan" },
  { mime = "application/*doc*", fg = "green" },
  { mime = "application/*sheet*", fg = "green" },
  { mime = "application/*presentation*", fg = "green" },

  # Fallback
  { name = "*", fg = "reset" },
  { name = "*/", fg = "blue", bold = true },
]

🐚 Oh-My-Zsh + Zoxide 配置

位置: ~/.zshrc

# =================== Oh-My-Zsh 配置 ===================
export ZSH="$HOME/.oh-my-zsh"

# 主题设置
ZSH_THEME="agnoster"

# 禁用自动更新
DISABLE_AUTO_UPDATE="true"

# 插件配置
plugins=(
    git
    zsh-syntax-highlighting
    zsh-autosuggestions
)

source $ZSH/oh-my-zsh.sh

# =================== 环境变量配置 ===================
export LANG=en_US.UTF-8

# 自动建议高亮样式
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE=fg=30

# 隐藏 agnoster 主题中的用户名@主机名
DEFAULT_USER="your_username"

# =================== Ghostty 标题设置为当前目录 ===================
if [[ -n "${GHOSTTY_RESOURCES_DIR:-}" ]]; then
    ghostty_set_title() {
        # 将 HOME 替换为 ~,保持标题更短
        local dir="${PWD/#$HOME/~}"
        # Ghostty 支持 OSC 2 设置窗口标题
        printf '\033]2;%s\033\\' "$dir"
    }

    autoload -Uz add-zsh-hook
    add-zsh-hook chpwd ghostty_set_title
    add-zsh-hook precmd ghostty_set_title
    add-zsh-hook preexec ghostty_set_title
    ghostty_set_title
fi

# =================== Yazi 文件管理器 ===================
function y() {
    local tmp="$(mktemp -t "yazi-cwd.XXXXXX")" cwd
    yazi "$@" --cwd-file="$tmp"
    if cwd="$(command cat -- "$tmp")" && [ -n "$cwd" ] && [ "$cwd" != "$PWD" ]; then
        builtin cd -- "$cwd"
    fi
    rm -f -- "$tmp"
}

# =================== Zoxide 智能目录跳转 ===================
eval "$(zoxide init zsh)"

📥 安装指南

1. 安装工具

# macOS (Homebrew)
brew install ghostty
brew install zoxide
brew install yazi
brew install ffmpegthumbnailer  # Yazi 视频预览
brew install poppler            # Yazi PDF 预览

# Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# Zsh 插件
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

2. 配置文件

# 创建配置目录
mkdir -p ~/.config/ghostty
mkdir -p ~/.config/yazi

# 复制配置文件(根据上面的配置内容创建)
# Ghostty: ~/.config/ghostty/config
# Yazi: ~/.config/yazi/{yazi.toml,keymap.toml,theme.toml}
# Zsh: ~/.zshrc

3. 重新加载配置

# 重新加载 Zsh 配置
source ~/.zshrc

# Ghostty 配置会在重启终端后生效
# 或使用快捷键 Cmd+Shift+, 重新加载

🎯 使用技巧

Zoxide 智能跳转

z work          # 跳转到包含 "work" 的目录
z foo bar       # 跳转到同时包含 "foo" 和 "bar" 的目录
zi work         # 交互式选择(如果有多个匹配)

Yazi 文件管理器

y               # 启动 Yazi(退出后会 cd 到当前目录)

# 快捷键(在 Yazi 中)
gh              # 跳转到 home 目录
gc              # 跳转到 .config 目录
gd              # 跳转到 Downloads 目录
gw              # 跳转到 work 目录
gD              # 跳转到 Desktop 目录
gt              # 跳转到 /tmp 目录

Ghostty 快捷键

Cmd+T           # 新建标签页
Cmd+D           # 垂直分屏
Cmd+Shift+D     # 水平分屏
Ctrl+`          # 全局快速终端(Quake 模式)
Cmd+Shift+,     # 重新加载配置

🎨 主题推荐

Ghostty 主题

  • Kanagawa Wave(当前使用)
  • Tokyo Night
  • Catppuccin
  • Nord
  • Dracula

查看所有主题:ghostty +list-themes

字体推荐

  • Maple Mono NF CN(当前使用)
  • JetBrains Mono Nerd Font
  • Fira Code Nerd Font
  • Cascadia Code Nerd Font

📝 注意事项

  1. Nerd Font: Yazi 和 Oh-My-Zsh 主题需要 Nerd Font 才能正确显示图标
  2. Shell Integration: Ghostty 的 shell integration 功能需要在配置中启用
  3. Zoxide: 需要使用一段时间后才能建立目录访问历史
  4. Yazi 预览: 需要安装额外的工具(ffmpegthumbnailer, poppler)才能预览视频和 PDF

🔗 相关链接


作者: lengleng 更新时间: 2026-03-23

@lltx
Copy link
Copy Markdown
Author

lltx commented Apr 2, 2026

hello,想问下oh-my-zsh是在服务器还是在本地配置?

都是本地的终端 , 你直接把当前的gist 链接扔给 claude code 让它自动参考这个文档去配置安装就行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment