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

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

吹く使用GNU読取りライン。 Readlineは一連のキーボードショートカットを提供します。ただし、Bashにはいくつかのショートカットを使用できます。そしてReadlineに文書化されていないもの引用する。いくつかの例は次のとおりです。

  • C-h- バックスペースキーと同じ
  • C-m- Enterと同じ(CRのようです)

それでは、これらのショートカットが機能するのはなぜですか?私の考えでは、これらは以下に関連していると思います。ASCIIコードしかし、どのコンポーネントがこれらの制御シーケンスを私が指示する動作として解釈するのかわかりません。

Readlineライブラリですか?それともバッシュ自体?これは私の端末エミュレータですか?カーネルですか?など...

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

編集:私の.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組み込みバインディングのいくつかを追加、変更、または削除することができます。

おすすめ記事