macOS 下基于 Ghostty + Starship + zsh 插件的终端美化方案,从 iTerm2 + oh-my-zsh 迁移而来,更轻量更快。
- 彩虹条提示符(基于 Starship 官方 catppuccin-powerline 预设,启用换行显示)
- 半透明毛玻璃窗口
- 语法高亮、自动建议、模糊搜索
| 文件 | 说明 | 安装位置 |
|---|---|---|
ghostty/config |
Ghostty 终端配置(字体、主题、窗口、光标) | ~/.config/ghostty/config |
starship/starship.toml |
Starship 彩虹条提示符配置(官方预设 + 换行) | ~/.config/starship.toml |
zsh/.zshrc |
zsh 配置(插件、工具、别名、快捷键) | ~/.zshrc |
bash <(curl -fsSL https://raw.githubusercontent.com/justhalfbit/ghostty-terminal-config/main/install.sh)安装前会询问确认,确认后自动执行:
- 通过 Homebrew 安装所有依赖
- 备份已有 Ghostty 和 Starship 配置文件
- 安装 Ghostty 和 Starship 配置(覆盖)
- 将 zsh 配置追加到
~/.zshrc尾部(不覆盖用户已有内容)
安装脚本会自动将已有配置备份到 ~/.config-backup/<时间戳>/ 目录。
备份文件对应关系:
| 备份文件 | 原始位置 |
|---|---|
~/.config-backup/<时间戳>/ghostty-config |
~/.config/ghostty/config |
~/.config-backup/<时间戳>/starship.toml |
~/.config/starship.toml |
恢复命令:
# 查看备份目录(找到对应时间戳)
ls ~/.config-backup/
# 恢复(替换 <时间戳> 为实际目录名)
cp ~/.config-backup/<时间戳>/ghostty-config ~/.config/ghostty/config
cp ~/.config-backup/<时间戳>/starship.toml ~/.config/starship.toml删除 ~/.zshrc 中 # >>> ghostty-terminal-config >>> 到 # <<< ghostty-terminal-config <<< 之间的所有内容即可。
| 工具 | 用途 |
|---|---|
| Ghostty | GPU 加速终端模拟器 |
| Starship | 跨 shell 提示符 |
| fzf | 模糊搜索(Ctrl+R 搜历史,Ctrl+T 搜文件) |
| zoxide | 智能目录跳转(z foo 代替 cd) |
| eza | 替代 ls,彩色图标 |
| bat | 替代 cat,语法高亮 |
| yazi | 终端文件管理器 |
| zsh-autosuggestions | 历史命令自动建议 |
| zsh-syntax-highlighting | 命令语法高亮 |
| zsh-completions | Tab 补全增强 |
| Maple Mono NF | 终端字体(Nerd Font,中文显示优秀) |
brew install --cask font-maple-mono-nf
brew install --cask ghostty
brew install starship fzf zoxide eza bat yazi zsh-autosuggestions zsh-syntax-highlighting zsh-completionsgit clone --depth 1 https://github.com/justhalfbit/ghostty-terminal-config.git /tmp/ghostty-configmkdir -p ~/.config/ghostty
cp /tmp/ghostty-config/ghostty/config ~/.config/ghostty/config
cp /tmp/ghostty-config/starship/starship.toml ~/.config/starship.toml
cat /tmp/ghostty-config/zsh/.zshrc >> ~/.zshrc注意:zsh 配置是追加到
~/.zshrc尾部,不会覆盖已有内容。如果重复执行需手动去重。
rm -rf /tmp/ghostty-config重启 Ghostty 终端生效。
彩虹条基于 starship preset catppuccin-powerline 官方预设,唯一改动:
[line_break] disabled = false:彩虹条一行,输入符号在下一行
| 快捷键 | 功能 |
|---|---|
Ctrl+F |
接受自动建议 |
Ctrl+R |
fzf 模糊搜索历史命令 |
Ctrl+T |
fzf 模糊搜索文件 |
Tab |
补全,连续按在候选列表中移动 |
| 别名 | 实际命令 |
|---|---|
ls |
eza --icons --group-directories-first |
ll |
eza -l --icons --sort=name |
lt |
eza --tree --icons --level=2 |
cat |
bat --paging=never --style=plain |
y |
yazi 文件管理器(退出自动 cd) |
z foo |
zoxide 智能跳转到包含 foo 的目录 |