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"
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
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.
Ah, the problem you describe is different than what I'm facing. You can get tmux to forward key combos like shift+left by setting the tmux option, set xterm-keys on.
So they key presses get passed, but micro doesn't interpret them correctly.
Right, tmux is sending xterm key combos even though the TERM is declared as screen, which is confusing micro because it doesn't expect a screen terminal to be sending xterm escape sequences.
Anyway to fudge it with an option like how tmux does? set xtermkeys on?
I suggest using set -g default-terminal "xterm-256color", though I'm not very familiar with tmux so it's possible this could cause other problems (there seem to be conflicting opinions online).
Did you try to start Micro as "TERM=xterm-256color micro" in tmux ? -- this is generally fixing for me any mismatch with Terminal / tmux / etc. settings..
Rgds, -Dimitri
Yes, switching TERM setting to xterm resolves the issue. This is fine for me, as IIRC, I originally modified tmux's reported TERM to make keys work in micro a couple years ago.
Best to use TERM=tmux-256color if you have it.
Last time I tried that, micro didn't like it at all. Wouldn't even launch.
I'll try again, when I get a chance.
On Tue, Feb 11, 2020, 16:33 Nicholas Marriott notifications@github.com
wrote:
Best to use TERM=tmux-256color if you have it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/zyedidia/micro/issues/1489?email_source=notifications&email_token=ADZRDXMWTCEC34J5PRV3J4LRCMKS5A5CNFSM4KSECGAKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELOE7RY#issuecomment-584863687,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ADZRDXMP36EFHKLCW5QJGPLRCMKS5ANCNFSM4KSECGAA
.
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.
I believe you need to have TERM=xterm-256color outside of tmux, and TERM=tmux-256color (not screen-256color!) inside of tmux. From the tmux FAQ:
tmux sends modified function keys using xterm(1)-style escape sequences. This can be verified using cat, for example pressing M-Left:
$ cat
^[[1;3D
If this is different, then TERM outside tmux is probably incorrect and tmux can't recognise the keys coming from the outside terminal.
If it is correct, then some applications inside tmux do not recognise these keys if TERM is set to screen or screen-256color, because these terminal descriptions lack the capabilities. The tmux and tmux-256color descriptions do have such capabilities, so using those instead may work.
I had the same issue and I can confirm that setting the xterm to true fixed it for me. Thank you!
I have a pretty good experience and will add some of my config here; I'm using konsole, zsh, and tmux.
TERM is xterm-256colorset -g default-terminal 'tmux-256color'
set -ga terminal-overrides ',*256col*:Tc:sitm=\E[3m'
set -g mouse on
setw -g xterm-keys on
setw -g mode-keys vi
EDIT: Shortened a bit as I think this was not received with welcome. I only wanted to add support for anyone it might benefit, as some folks still need or think they need the -xterm option.
I have a pretty good experience and will add some of my config here; I'm using konsole, zsh, and tmux.
* outside tmux, `TERM` is `xterm-256color` * some relevant lines from my tmux config:set -g default-terminal 'tmux-256color' set -ga terminal-overrides ',*256col*:Tc:sitm=\E[3m' set -g mouse on setw -g xterm-keys on setw -g mode-keys viAnd FWIW my micro bindings (I don't remember if there's a reason for the first one, I use
ctrl, notalt, in practice):{ "Alt-/": "lua:comment.comment", "Alt2": "VSplit", "AltDown": "MoveLinesDown", "AltLeft": "PreviousSplit", "AltRight": "NextSplit", "AltUp": "MoveLinesUp", "CtrlBackspace": "DeleteWordLeft", "CtrlG": "command-edit:goto ", "CtrlK": "DeleteLine", "CtrlL": "SelectLine", "CtrlLeft": "WordLeft", "CtrlRight": "WordRight", "CtrlShiftLeft": "SelectWordLeft", "CtrlShiftRight": "SelectWordRight", "CtrlUnderscore": "lua:comment.comment", "Esc": "RemoveAllMultiCursors", "F3": "FindNext", "ShiftEnd": "SelectToEndOfLine", "ShiftF3": "FindPrevious", "ShiftHome": "SelectToStartOfLine" }
Yeah, that's because you have TERM=xterm-256color outside of tmux, and TERM=tmux-256color inside of tmux, as I mentioned.
This is solved now with the newest version of tcell. Micro now accepts TERM=tmux-256color.
Most helpful comment
I've added the
xtermoption, which will cause micro to think the$TERMisxterm-256colorregardless of what it actually is. It's not a great solution, but it should resolve your problem without requiring you to change theTERMvariable.