bash のキーボード ショートカット Ch、Cm

bash のキーボード ショートカット Ch、Cm

バッシュ用途GNU Readline。Readlineはキーボードショートカットのコレクションを提供します。ただし、bashで機能するショートカットがいくつかあります。そしてReadlineに文書化されていないもの参照いくつかの例を以下に示します。

  • C-h- バックスペースと同じ
  • C-m- Enterと同じ(CRだと思います)

では、なぜこれらのショートカットが機能するのでしょうか?これはおそらく次のようなことと関係があると思います。アスキーしかし、どのコンポーネントがこれらの制御シーケンスを私が示した動作として解釈するかはわかりません。

Readline ライブラリでしょうか? それとも bash 自体でしょうか? 端末エミュレータでしょうか? カーネルでしょうか? などなど...

これらの制御シーケンスをこのように動作させるコンポーネントは何ですか?

編集: 私の.inputrcファイル:

# To the extent possible under law, the author(s) have dedicated all 
# copyright and related and neighboring rights to this software to the 
# public domain worldwide. This software is distributed without any warranty. 
# You should have received a copy of the CC0 Public Domain Dedication along 
# with this software. 
# If not, see <http://creativecommons.org/publicdomain/zero/1.0/>. 

# base-files version 4.2-4

# ~/.inputrc: readline initialization file.

# The latest version as installed by the Cygwin Setup program can
# always be found at /etc/defaults/etc/skel/.inputrc

# Modifying /etc/skel/.inputrc directly will prevent
# setup from updating it.

# The copy in your home directory (~/.inputrc) is yours, please
# feel free to customise it to create a shell
# environment to your liking.  If you feel a change
# would be benifitial to all, please feel free to send
# a patch to the cygwin mailing list.

# the following line is actually
# equivalent to "\C-?": delete-char
"\e[3~": delete-char

# VT
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# kvt
"\e[H": beginning-of-line
"\e[F": end-of-line

# rxvt and konsole (i.e. the KDE-app...)
"\e[7~": beginning-of-line
"\e[8~": end-of-line

# VT220
"\eOH": beginning-of-line
"\eOF": end-of-line

# Allow 8-bit input/output
#set meta-flag on
#set convert-meta off
#set input-meta on
#set output-meta on
#$if Bash
  # Don't ring bell on completion
  #set bell-style none

  # or, don't beep at me - show me
  #set bell-style visible

  # Filename completion/expansion
  #set completion-ignore-case on
  #set show-all-if-ambiguous on

  # Expand homedir name
  #set expand-tilde on

  # Append "/" to all dirnames
  #set mark-directories on
  #set mark-symlinked-directories on

  # Match all files
  #set match-hidden-files on

  # 'Magic Space'
  # Insert a space character then performs
  # a history expansion in the line
  #Space: magic-space
#$endif

答え1

バインディングは(マニュアルに記載されているかどうかに関係なく)入力すると表示されます。

bind -p

たとえば(一部抜粋):

"\C-g": abort
"\C-x\C-g": abort
"\e\C-g": abort
"\C-j": accept-line
"\C-m": accept-line
# alias-expand-line (not bound)
# arrow-key-prefix (not bound)
# backward-byte (not bound)
"\C-b": backward-char
# backward-byte (not bound)
"\C-b": backward-char
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\e[3;5~": backward-delete-char
"\C-?": backward-delete-char
"\C-x\C-?": backward-kill-line
"\e\C-h": backward-kill-word
"\e\C-?": backward-kill-word
"\eb": backward-word
"\e<": beginning-of-history

マニュアルには-pオプションが記載されています:

bind -pコマンド表示読み込まれた行関数名とバインディングを初期化ファイルに直接配置できる形式で記述します。Bash 組み込み

バインディング(ソースコードを読む)はキーマップに依存します。私が引用したものはemacs キーマップスクリプトが適用される前に組み込みテーブルから初期化されます。対応するファイルには、vi キーマップ

これらはすべて読み込まれた行( にバンドルされていますbash)bashが起動すると、これらのテーブルを使用してバインディングが定義されます。 から読み取る他のファイルに応じて/etc/inputrc~/.inputrcこれらの組み込みバインディングの一部が追加、変更、または削除される場合があります。

答え2

参照したマニュアルのセクション「1.3 Readline Init File」で指摘されているように、readline ライブラリは設定可能です。キーバインディングは/etc/inputrc、 またはローカルの のいずれかで定義できます~/.inputrc

関連情報