Linux キーバインドを表示する

Linux キーバインドを表示する

Linuxで、キーバインドを表示する手順を記述してます。

環境

  • OS Rocky Linux release 8.4 (Green Obsidian)
  • shell: /bin/bash

キーバインドを表示

親子関係を表示するには、「 bind 」コマンドのオプション「-P」を使用します。

実際に、確認してみます。

bind -P

<出力結果>
abort can be found on "\C-g", "\C-x\C-g", "\e\C-g".
accept-line can be found on "\C-j", "\C-m".
alias-expand-line is not bound to any keys
arrow-key-prefix is not bound to any keys
backward-byte is not bound to any keys
backward-char can be found on "\C-b", "\eOD", "\e[D".
backward-delete-char can be found on "\C-h", "\C-?".
backward-kill-line can be found on "\C-x\C-?".
backward-kill-word can be found on "\e\C-h", "\e\C-?".
backward-word can be found on "\eOd", "\e[1;5D", "\e[5D", "\eb".
beginning-of-history can be found on "\e<".
beginning-of-line can be found on "\C-a", "\eOH", "\e[1~", "\e[H".
bracketed-paste-begin can be found on "\e[200~".
call-last-kbd-macro can be found on "\C-xe".
capitalize-word can be found on "\ec".
character-search can be found on "\C-]".
character-search-backward can be found on "\e\C-]".
clear-screen can be found on "\C-l".
complete can be found on "\C-i", "\e\e".
complete-command can be found on "\e!".
complete-filename can be found on "\e/".
complete-hostname can be found on "\e@".

取得されていることが確認できます。

キー設定の一覧は、オプション「-p」で確認できます。

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
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\C-?": backward-delete-char
"\C-x\C-?": backward-kill-line
"\e\C-h": backward-kill-word
"\e\C-?": backward-kill-word
"\eOd": backward-word
"\e[1;5D": backward-word
"\e[5D": backward-word
"\eb": backward-word
"\e<": beginning-of-history
"\C-a": beginning-of-line
"\eOH": beginning-of-line
"\e[1~": beginning-of-line
"\e[H": beginning-of-line
"\e[200~": bracketed-paste-begin
"\C-xe": call-last-kbd-macro
"\ec": capitalize-word
"\C-]": character-search
"\e\C-]": character-search-backward
"\C-l": clear-screen
"\C-i": complete
"\e\e": complete

既に割当られているキーの一覧は、以下で確認可能です。

bind -p | grep -v "not bound" | more

<出力結果>
"\C-g": abort
"\C-x\C-g": abort
"\e\C-g": abort
"\C-j": accept-line
"\C-m": accept-line
"\C-b": backward-char
"\eOD": backward-char
"\e[D": backward-char
"\C-h": backward-delete-char
"\C-?": backward-delete-char
"\C-x\C-?": backward-kill-line
"\e\C-h": backward-kill-word
"\e\C-?": backward-kill-word
"\eOd": backward-word
"\e[1;5D": backward-word
"\e[5D": backward-word
"\eb": backward-word
"\e<": beginning-of-history