
세게 때리다용도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
명령 표시Readline초기화 파일에 직접 넣을 수 있는 형식의 함수 이름 및 바인딩입니다. 보다배쉬 내장.
바인딩(소스 코드 읽기)은 키맵에 따라 다릅니다. 제가 인용한 것들은 다음에서 나온 것입니다.이맥스 키맵, 스크립트가 적용되기 전에 내장 테이블에서 초기화됩니다. 해당 파일에 대한 테이블이 있습니다.vi 키맵.
그 모든 것의 일부입니다Readline(와 함께 번들로 제공됨 bash
). 시작 시 bash
이러한 테이블을 사용하여 바인딩을 정의합니다. 에서 읽는 다른 파일에 따라 /etc/inputrc
이러한 ~/.inputrc
내장 바인딩 중 일부를 추가, 수정 또는 제거할 수 있습니다.
답변2
참조하는 매뉴얼의 "1.3 Readline Init File" 섹션에서 지적했듯이 readline 라이브러리는 구성 가능합니다. 키 바인딩은 /etc/inputrc
, 또는 로컬 에서 정의할 수 있습니다 ~/.inputrc
.