是什么

terminal-config 解决 Claude Code 在特定终端环境中的显示和交互问题,包括多行输入、Option 键快捷键、通知、tmux 集成和 Vim 模式。Claude Code 在任何终端中无需配置即可工作,本页面针对特定症状提供解决方案。

核心机制

多行输入

  • 通用方法:Ctrl+J 或 \ 后按 Enter(所有终端均支持)
  • Shift+Enter:大多数现代终端原生支持,VS Code/Cursor/Alacritty/Zed 需运行 /terminal-setup
  • gnome-terminal、JetBrains IDE:不支持 Shift+Enter,使用 Ctrl+J

Shift+Enter 支持情况

终端状态
Ghostty, Kitty, iTerm2, WezTerm, Warp, Apple Terminal, Windows Terminal原生支持
VS Code, Cursor, Windsurf, Alacritty, Zed运行 /terminal-setup 一次
gnome-terminal, JetBrains IDEs不支持

Option 键(macOS)

  • Apple Terminal:Settings → Profiles → Keyboard → “Use Option as Meta Key”
  • iTerm2:Settings → Profiles → Keys → Left/Right Option key → “Esc+”
  • VS Code:"terminal.integrated.macOptionIsMeta": true

通知配置

  • 默认:Ghostty、Kitty、iTerm2 支持桌面通知
  • 其他终端:设置 preferredNotifChannel: "terminal_bell" 使用终端铃声
  • 自定义声音:配置 Notification hook

tmux 配置

# ~/.tmux.conf
set -g default-terminal "tmux-256color"
set -as terminal-features ",*:RGB"
# 支持 Shift+Enter
bind-key -n S-Enter send-keys Enter

在 tmux 内使用 Shift+Enter 还需要外层终端支持。

Vim 模式 运行 /terminal-setup 或在 keybindings 中配置,在 prompt 输入框中使用 Vim 键位。

关键细节

  • /terminal-setup 在 VS Code/Cursor/Windsurf 中还会设置 terminal.integrated.mouseWheelScrollSensitivity 优化 fullscreen 模式滚动
  • 在 tmux 或 screen 内部运行 /terminal-setup 无效,需在宿主终端中运行
  • SSH 远程 session 中桌面通知可以转发到本地机器(Ghostty/Kitty 自动支持,iTerm2 需额外配置)

与其他概念的关联

  • keybindings - Claude Code 内部快捷键自定义
  • fullscreen - 全屏渲染模式(解决闪烁和滚动问题)

实践要点

  • 遇到 Shift+Enter 提交而非换行:先检查终端类型,再决定是否运行 /terminal-setup
  • tmux 用户:同时需要配置 tmux.conf 和外层终端的 Shift+Enter 支持
  • 长任务场景:配置通知避免频繁切换窗口检查进度