少なくとも私の場合は、WindowsマシンからPuttyを使用してdebianおよびUbuntuマシンへのセッションを開始するとき、alt-left/right
コマンドラインで単語ごとに移動するように機能します。 (多くの場合、これはctr-left/right
を使用するLinuxシステムでも実現されます。 。
しかし、屏風を使い始めたら、と (F9メニューを使用して)自動的に開始するように屏風を設定し、alt-left/right
もう動作しません。代わりに、Ctrl-V
を使用して生の文字を出力する場合 表示されます
^[[1;3C
— alt-right
を送信する場合 。一方、屏風はログイン時に自動的に起動せず、ログイン後に手動で起動した場合、送信すると推測しました
^[^[[C
これはデフォルトのinputrc構成によってキャッチされ、その結果、単語ごとに移動するように変換されます。
受け取ったコマンドにこの違いをもたらすために、ホスト/ターミナル/屏風であるパテの間でどのようなメカニズムが働いていますか?
承認された回答:
byobuはtmuxの単なるラッパーであり、表示されている動作を担当します。 tmuxは、「キー」を、xtermが変更された特殊キーをエンコードする文字シーケンスに変換しようとしています。マニュアルでは、それは文書化されています:
xterm-keys [on | off]
If this option is set, tmux will generate xterm(1) -style
function key sequences; these have a number included to
indicate modifiers such as Shift, Alt or Ctrl. The
default is off.
ただし、新しい/最近のバージョンでは、デフォルトはオンであると報告されています 。これにより、このコミットメッセージに見られる問題が明らかになりました:
commit d52f579fd5e7fd21d7dcf837780cbf98498b10ce
Author: nicm <nicm>
Date: Sun May 7 21:25:59 2017 +0000
Up to now, tmux sees \033\033[OA as M-Up and since we turned on
xterm-keys by default, generates \033[1;3A instead of
\033\033[OA. Unfortunately this confuses vi, which doesn't understand
xterm keys and now sees Escape+Up pressed within escape-time as Escape
followed by A.
The issue doesn't happen in xterm itself because it gets the keys from X
and can distinguish between a genuine M-Up and Escape+Up.
Because xterm can, tmux can too: xterm will give us \033[1;3A (that is,
kUP3) for a real M-Up and \033\033OA for Escape+Up - in fact, we can be
sure any \033 preceding an xterm key is a real Escape key press because
Meta would be part of the xterm key instead of a separate \033.
So change tmux to recognise both sequences as M-Up for its own purposes,
but generate the xterm version of M-Up only if it originally received
the xterm version from the terminal.
This means we will return to sending \033\033OA instead of the xterm key
for terminals that do not support xterm keys themselves, but there is no
practical way around this because they do not allow us to distinguish
between Escape+Up and M-Up. xterm style escape sequences are now the de
facto standard for these keys in any case.
Problem reported by [email protected] and subsequently by Cecile Tonglet in GitHub
issue 907.