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 내장 기능.

바인딩(소스 코드 읽기)은 키맵에 따라 다릅니다. 제가 인용한 내용은이맥스 키맵, 스크립트를 적용하기 전에 내장 테이블에서 초기화됩니다. 테이블을 포함하는 해당 파일이 있습니다vi 키맵.

이것들은 모두독서선(번들과 함께 bash). bash시작 시 이러한 테이블을 사용하여 바인딩을 정의합니다. 읽는 다른 파일에 따라 /etc/inputrc이러한 ~/.inputrc내장 바인딩 중 일부를 추가, 수정 또는 제거할 수 있습니다.

답변2

참조하는 매뉴얼의 "1.3 Readline Init File" 섹션에 언급된 대로 readline 라이브러리는 구성 가능합니다. 키 바인딩은 in /etc/inputrc또는 local 일 수 있습니다 ~/.inputrc.

관련 정보