bash : input mode

0. bash options

  • $ set -o : 옵션 보기
jsg@jsg-ubuntu:~$ set -o
allexport      	off
braceexpand    	on
emacs          	on
errexit        	off
errtrace       	off
functrace      	off
hashall        	on
histexpand     	on
history        	on
ignoreeof      	off
interactive-comments	on
keyword        	off
monitor        	on
noclobber      	off
noexec         	off
noglob         	off
nolog          	off
notify         	off
nounset        	off
onecmd         	off
physical       	off
pipefail       	off
posix          	off
privileged     	off
verbose        	off
vi             	off
xtrace         	off

Ⅰ. Emacs Mode


  • bash 기본 모드
  • $set -o emacs

1. 커서 이동

단축키설명
Ctrl-F / →앞으로 1칸 이동
Ctrl-B / ←뒤로 1칸 이동
Alt-F / Ctrl-→한단어 앞으로 이동
Alt-B / Ctrl-←한단어 뒤로 이동
Ctrl-A맨 뒤로 이동
Ctrl-E맨 앞으로 이동

2. 탐색

단축키설명
Ctrl-P / ↑이전 명령어
Ctrl-N / ↓앞 명령어
Tab자동 완성
Tab x 2prefix와 매칭되는 단어 목록
Esc-*prefix와 매칭되는 단어 프롬프트에 복사
Ctrl-R이전 명령어에서 후방탐색 / 더 누르면 재탐색
  • 이전 명령어에서 전방탐색 단축키를 쓰고 싶을 때
    ~/.bashrc 에 stty stop '' 추가하면 Ctrl-S 로 쓸 수 있음

3. 지우기

단축키설명
BackSpace뒷글자 삭제
Ctrl-D / Delete앞글자 삭제
Alt-BackSpace / Ctrl-W뒤로 한 단어 삭제
Esc-D앞으로 한 단어 삭제
Ctrl-K앞 글자 모두 삭제
Ctrl-U뒤 글자 모두 삭제

4. 이전 argument 불러오기

단축키설명
!:n이전 명령어의 nth argument
!:n-m이전 명령어의 nth~mth argument
!$이전 명령어의 마지막 argument
!^이전 명령어의 첫 argument
!*이전 명령어의 전체 argument
Alt-.!$ 의 단축키

5. 기타

단축키설명
Ctrl-Lclear
Ctrl-_undo
Ctrl-Y잘라낸 문자 붙여넣기

Ⅱ. Vi Mode


  • ksh 기본 모드
  • $set -o vi
  • vim 사용법과 같음
단축키설명
j / k이전 / 앞 명령어
#G#번째 명령어
=prefix와 매칭되는 단어 목록
*prefix와 매칭되는 단어 목록 프롬프트에 복사
/ , ?명령어 전후방 탐색

좋은 웹페이지 즐겨찾기