Skip to content

Latest commit

 

History

History
152 lines (105 loc) · 5.48 KB

terminal-setup.md

File metadata and controls

152 lines (105 loc) · 5.48 KB

Terminal Setup

Diffex uses the Kitty keyboard protocol for reliable modifier key detection. Most modern terminals support this protocol, but some require configuration.

Terminal focus and tmux

Diffex uses terminal focus reporting to pause cursor animation when its terminal window or pane is not active. When reliable focus reporting is unavailable, the placeholder cursor remains static. To receive pane focus changes inside tmux and keep the focused-pane animation, add this to ~/.tmux.conf:

set -g focus-events on

Detach and reattach existing tmux clients after changing this option.

Kitty, iTerm2

Work out of the box.

Apple Terminal

Diffex enables enhanced key reporting when available. If Terminal.app still sends plain Return for Shift+Enter, Diffex uses a local macOS modifier fallback to treat that Return as Shift+Enter.

This fallback only works when Diffex runs on the same Mac as Terminal.app. It cannot detect the local keyboard over remote SSH.

Ghostty

Add to your Ghostty config (~/Library/Application Support/com.mitchellh.ghostty/config on macOS, ~/.config/ghostty/config on Linux):

keybind = alt+backspace=text:\x1b\x7f

Older Claude Code versions may have added this Ghostty mapping:

keybind = shift+enter=text:\n

That mapping sends a raw linefeed byte. Inside Diffex, that is indistinguishable from Ctrl+J, so tmux and Diffex no longer see a real shift+enter key event.

If Claude Code 2.x or newer is the only reason you added that mapping, you can remove it, unless you want to use Claude Code in tmux, where it still requires that Ghostty mapping.

Diffex binds Ctrl+J as a default newline alias, so Shift+Enter keeps working in tmux via that remap without extra Diffex configuration.

WezTerm

WezTerm usually works out of the box for Shift+Enter via xterm modifyOtherKeys. To use the Kitty keyboard protocol explicitly, create ~/.wezterm.lua:

local wezterm = require 'wezterm'
local config = wezterm.config_builder()
config.enable_kitty_keyboard = true
return config

On macOS, WezTerm binds Option+Enter to fullscreen by default. To use Option+Enter for Diffex follow-up queueing, add this key override:

local wezterm = require 'wezterm'
local config = wezterm.config_builder()
config.keys = {
  {
    key = 'Enter',
    mods = 'ALT',
    action = wezterm.action.SendString('\x1b[13;3u'),
  },
}
return config

If you already have a config.keys table, add the entry to it.

On WSL, WezTerm may require a visible hardware cursor for IME candidate window positioning. If CJK IME candidates do not follow the text cursor, set DIFFEX_HARDWARE_CURSOR=1 before running Diffex or set showHardwareCursor to true in settings.

Alacritty

Alacritty usually works out of the box for Shift+Enter. On macOS, Option+Enter may arrive as plain Enter. To use Option+Enter for Diffex follow-up queueing, add to ~/.config/alacritty/alacritty.toml:

[[keyboard.bindings]]
key = "Enter"
mods = "Alt"
chars = "\u001b[13;3u"

Restart Alacritty after changing the config.

VS Code (Integrated Terminal)

VS Code 1.109.5 and newer enable Kitty keyboard protocol in the integrated terminal by default, so Shift+Enter should work out of the box.

VS Code versions older than 1.109.5 need an explicit terminal keybinding for Shift+Enter.

keybindings.json locations:

  • macOS: ~/Library/Application Support/Code/User/keybindings.json
  • Linux: ~/.config/Code/User/keybindings.json
  • Windows: %APPDATA%\\Code\\User\\keybindings.json

Add to keybindings.json:

{
  "key": "shift+enter",
  "command": "workbench.action.terminal.sendSequence",
  "args": { "text": "\u001b[13;2u" },
  "when": "terminalFocus"
}

Windows Terminal

Add to settings.json (Ctrl+Shift+, or Settings → Open JSON file) to forward the modified Enter keys Diffex uses:

{
  "actions": [
    {
      "command": { "action": "sendInput", "input": "\u001b[13;2u" },
      "keys": "shift+enter"
    },
    {
      "command": { "action": "sendInput", "input": "\u001b[13;3u" },
      "keys": "alt+enter"
    }
  ]
}
  • Shift+Enter inserts a new line.
  • Windows Terminal binds Alt+Enter to fullscreen by default. That prevents Diffex from receiving Alt+Enter for follow-up queueing.
  • Remapping Alt+Enter to sendInput forwards the real key chord to Diffex instead.

If you already have an actions array, add the objects to it. If the old fullscreen behavior persists, fully close and reopen Windows Terminal.

xfce4-terminal, terminator

These terminals have limited escape sequence support. Modified Enter keys like Ctrl+Enter and Shift+Enter cannot be distinguished from plain Enter, preventing custom keybindings such as submit: ["ctrl+enter"] from working.

For the best experience, use a terminal that supports the Kitty keyboard protocol:

IntelliJ IDEA (Integrated Terminal)

The built-in terminal has limited escape sequence support. Shift+Enter cannot be distinguished from Enter in IntelliJ's terminal.

If you want the hardware cursor visible, set DIFFEX_HARDWARE_CURSOR=1 before running Diffex (disabled by default for compatibility).

Consider using a dedicated terminal emulator for the best experience.