Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tmux + micro text editor: shift-arrow echo keycode

Tags:

linux

ubuntu

tmux

With Ubuntu 20.04.3, tmux 3.0a, and micro text editor v2.0.10, when using the micro text editor within a tmux window, typing modifier key + arrows just echos the text of the key code instead of performing the navigation or selection actions.

~/.tmux.conf doesn't have key bindings associated to Shift-arrows, Ctrl-arrows, Alt-arrows, nor Ctrl-Shift-arrows. Content of the micro editor when typing xxx-arrows:

Shift Left/Right: [1;2D] [1;2C]
Shift Up/Down   : [1;2A] [1;2B]
Ctrl  Left/Right: [1;5D] [1;5C]
Ctrl  Up/Down   : [1;5A] [1;5B]
C-Sht Left/Right: [1;6D] [1;6C]
C-Sht Up/Down   : [1;6A] [1;6B]
Alt Left/Right  : [1;3D] [1;3C]
Alt Up/Down     : [1;3A] [1;3D]

Running micro outside of tmux, for example in Gnome terminal, there is no problem; the modifier key + arrows perform their intended actions. But running Nano or Vim within tmux, the modifier key + arrows do not echo the keycode [1;xx] in the editor area.

I tried to enable the following options in ~/.tmux.conf (and reload the config):

  • set-window-option -g xterm-keys on
  • set-option -g xterm-keys on

There is no improvement with either or both of these options enabled. Is this related to tmux or the micro text editor? And is there is a fix?

like image 235
Polymerase Avatar asked Aug 11 '26 11:08

Polymerase


1 Answers

Workaround (by micro author): https://github.com/zyedidia/micro/issues/983#issuecomment-355867571

Edit ~/.config/micro/bindings.json, add

{
    "\u001b[1;2A": "SelectUp",
    "\u001b[1;2B": "SelectDown",
    "\u001b[1;2C": "SelectRight",
    "\u001b[1;2D": "SelectLeft",
    "\u001b[1;3D": "WordLeft",
    "\u001b[1;3C": "WordRight",
    "\u001b[1;3A": "MoveLinesUp",
    "\u001b[1;3B": "MoveLinesDown",
    "\u001b[1;4C": "SelectWordRight",
    "\u001b[1;4D": "SelectWordLeft",
    "\u001b[1;5D": "StartOfLine",
    "\u001b[1;5C": "EndOfLine",
    "\u001b[1;6D": "SelectToStartOfLine",
    "\u001b[1;6C": "SelectToEndOfLine",
    "\u001b[1;5A": "CursorStart",
    "\u001b[1;5B": "CursorEnd",
    "\u001b[1;6A": "SelectToStart",
    "\u001b[1;6B": "SelectToEnd"
}
like image 70
Polymerase Avatar answered Aug 14 '26 07:08

Polymerase



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!