micro: Key-press sequences broken under tmux

Description of the problem or steps to reproduce

Go to “raw” mode to show key presses. Press a key combo, like shift + left arrow. Directly from Konsole you see this interpretted as a single key press:

EventKey: “\x1b[1;2D”

However, under tmux you see the escape sequence as several separate key presses:

EventKey: “\x1b[”
EventKey: “1”
EventKey: “;”
EventKey: “2”
EventKey: “D”

Specifications

You can use micro -version to get the commit hash. v2.0.0.rc3.8a907956-1 Commit hash: 8a907956 OS: ArchLinux Terminal: Konsole / cool-retro-term / tmux

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (7 by maintainers)

Commits related to this issue

Most upvoted comments

This is solved now with the newest version of tcell. Micro now accepts TERM=tmux-256color.

I’ve added the xterm option, which will cause micro to think the $TERM is xterm-256color regardless of what it actually is. It’s not a great solution, but it should resolve your problem without requiring you to change the TERM variable.

This appears to be caused by tmux declaring TERM=screen. I’m not certain, but it seems likely that the screen terminfo doesn’t declare the escape sequences for modified arrow keys, though tmux sends them anyway. I’m not sure if there’s a good fix for this (maybe just recognize those escape sequences regardless of the terminfo?) but one thing is you can declare TERM=xterm or TERM=xterm-256color and as it seems like the escape sequences that tmux is sending are more aligned with the xterm terminfo.