1

inputrc にメタ キーのバインドを追加して、readline を拡張しようとしています。ターミナル (OSX) を使用しています

理想的には追加したい"\M-h": "\C-w"

ただし、メタ キーをバインドできないようです。オプションキーをメタとして扱うターミナルにオプションがあります。結果、問題なく入ることができM-bました。私のinputrcでそれにバインドしてもうまくいきません。

sed -nl端末に送信されたエスケープシーケンスを記録するために使用してみました。M-xoutputsを押します^[hが、バインディングのようなもの"^[h":"\C-w"は機能しません。助けていただければ幸いです。

編集:これは、送信される ansi エスケープ キーに基づいてバインドする方法を示す readline ドキュメントのサンプル ファイルです。おそらく、送信されている正しいエスケープキーにマッピングしていません.sedよりも良い確認方法はありますか?

4

2 に答える 2

1

私の質問に対する解決策は、次のバインディングです。"\eh": "\C-w"

\ereadline の Esc キーへのマッピングです。

メタ キーがないキーボードでは、メタ キーを表す統一された方法はありません。結果として:

Mac OS X ターミナルの「option as meta key」オプションは >「ESC 付きプレフィックス」のみを意味する - Chris Page

そのため、ターミナルは Meta を Option として扱い、Esc を readline に送信します。

于 2015-03-19T16:54:23.903 に答える
0

それはそれをバインドする正しい方法ですか?keyname:function-name ではないでしょうか? しかし、それを略奪しませんでした。

マニュアルページから:

   Readline Key Bindings
   The syntax for controlling key bindings in the inputrc file is simple.  All that is required is the name of the command or the text of a macro and a key sequence to which
   it should be bound. The name may be specified in one of two ways: as a symbolic key name, possibly with Meta- or Control- prefixes, or as a key sequence.

   When using the form keyname:function-name or macro, keyname is the name of a key spelled out in English.  For example:

          Control-u: universal-argument
          Meta-Rubout: backward-kill-word
          Control-o: "> output"

   In the above example, C-u is bound to the function universal-argument, M-DEL is bound to the function backward-kill-word, and C-o is bound to run the macro  expressed  on
   the right hand side (that is, to insert the text \u2018\u2018> output\u2019\u2019 into the line).

   In  the  second  form,  "keyseq":function-name or macro, keyseq differs from keyname above in that strings denoting an entire key sequence may be specified by placing the
   sequence within double quotes.  Some GNU Emacs style key escapes can be used, as in the following example, but the symbolic character names are not recognized.

          "\C-u": universal-argument
          "\C-x\C-r": re-read-init-file
          "\e[11~": "Function Key 1"

   In this example, C-u is again bound to the function universal-argument.  C-x C-r is bound to the function re-read-init-file, and ESC [ 1 1 ~ is bound to insert  the  text
   \u2018\u2018Function Key 1\u2019\u2019.

また、/etc/inputrc を調べることを検討することもできます。デフォルトのバインディングが存在します。

于 2015-03-19T12:14:05.280 に答える