[BUG] WezTerm /terminal-setup fails with keybind setups

Resolved 💬 3 comments Opened Jan 1, 2026 by xHeaven Closed Jan 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Claude Code's /terminal-setup breaks WezTerm with custom keybinds.

The regex used to find and replace the config.keys table is:

/config\.keys\s*=\s*\{[^}]*\}/s

The pattern [^}]* matches any character except }. This fails when there are nested braces. See reprod below.

What Should Happen?

The /terminal-setup command shouldn't break my terminal.

Steps to Reproduce

  1. Create a WezTerm config with special keybinds, such as:
-- macOS-style text editor keybindings
config.keys = {
  -- Option+Left: move back one word
  { key = 'LeftArrow', mods = 'OPT', action = act.SendKey { key = 'b', mods = 'ALT' } },
  -- Option+Right: move forward one word
  { key = 'RightArrow', mods = 'OPT', action = act.SendKey { key = 'f', mods = 'ALT' } },
  -- Cmd+Left: move to beginning of line
  { key = 'LeftArrow', mods = 'CMD', action = act.SendKey { key = 'a', mods = 'CTRL' } },
  -- Cmd+Right: move to end of line
  { key = 'RightArrow', mods = 'CMD', action = act.SendKey { key = 'e', mods = 'CTRL' } },
  -- Cmd+Backspace: delete to beginning of line
  { key = 'Backspace', mods = 'CMD', action = act.SendKey { key = 'u', mods = 'CTRL' } }
  1. Run /terminal-setup in Claude Code using WezTerm.
  2. WezTerm is broken due to the syntax error in the keybind setup:
-- macOS-style text editor keybindings
config.keys = {-- Option+Left: move back one word
  { key = 'LeftArrow', mods = 'OPT', action = act.SendKey { key = 'b', mods = 'ALT',
  {key="Enter", mods="SHIFT", action=wezterm.action{SendString="\x1b\r"}},} },
  -- Option+Right: move forward one word
  { key = 'RightArrow', mods = 'OPT', action = act.SendKey { key = 'f', mods = 'ALT' } },
  -- Cmd+Left: move to beginning of line
  { key = 'LeftArrow', mods = 'CMD', action = act.SendKey { key = 'a', mods = 'CTRL' } },
  -- Cmd+Right: move to end of line
  { key = 'RightArrow', mods = 'CMD', action = act.SendKey { key = 'e', mods = 'CTRL' } },
  -- Cmd+Backspace: delete to beginning of line
  { key = 'Backspace', mods = 'CMD', action = act.SendKey { key = 'u', mods = 'CTRL' } }

Claude Model

None

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.0.76

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

We could work around this with a proper Lua parser if we really want to support WezTerm, or provide the user with instructions on how to set up their terminal instead of completely breaking it.

WezTerm version used: wezterm 20240203-110809-5046fc22 (latest)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗