C.W.K.
Stream
Lesson 09 of 10 · published

키보드 단축키 — Readline / Zsh

~15 min · readline, shortcuts, emacs-keys, vi-mode

Level 0창 구경꾼
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

왜 단축키 익혀?

Shell 은 command 실행기만이 아니야 — 지금 줄에 대한 텍스트 에디터야. Bash / zsh 둘 다 Readline 라이브러리 (또는 같은 키 바인딩을 베낀 zsh 의 ZLE) 를 써. 단축키 6~7 개만 익히면 화살표 안 누르게 되고, 손이 홈 row 에 머물러.

이동

  • Ctrl+A — 줄 시작
  • Ctrl+E — 줄 끝
  • Alt+B / Alt+F — 단어 뒤 / 앞
  • Ctrl+B / Ctrl+F — 글자 뒤 / 앞

편집

  • Ctrl+W — 직전 단어 삭제 (shell 에서 가장 많이 쓰는 단축키)
  • Ctrl+U — 커서부터 줄 시작까지 삭제
  • Ctrl+K — 커서부터 줄 끝까지 삭제
  • Ctrl+Y — 마지막에 삭제된 거 붙여넣기 (kill ring)
  • Ctrl+T — 인접한 두 글자 swap

history

  • Ctrl+R — incremental reverse search. 글자 치면서 Enter 로 실행, 다시 Ctrl+R 누르면 다음 매치
  • Ctrl+P / Ctrl+N — 이전 / 다음 (화살표랑 동일)
  • !! — 직전 command. sudo !! 면 sudo 로 다시 실행.
  • !$ — 직전 command 의 마지막 argument. cat /long/path; vim !$ 패턴이 일품.

프로세스 제어

  • Ctrl+C — 실행 중 command 인터럽트
  • Ctrl+Z — suspend (나중에 fg 로 복귀)
  • Ctrl+D — EOF. 줄이 비어 있으면 shell 종료
  • Ctrl+L — 화면 클리어 (clear 와 동일)

vim 출신용 vi mode

set -o vi (bash) 또는 bindkey -v (zsh) 로 프롬프트를 modal 에디터로 바꿀 수 있어. Esc 로 normal 진입 후 vim 모션 그대로: w, b, 0, $, dd, cc. 다음 트랙의 fzf 통합과 엮으면 프롬프트가 작은 vim 이 돼.

Code

killer 단축키 연습·bash
# Type a long command, then practice these:
echo 'this is a long sample command for practice'
# Press Ctrl+A (start), Ctrl+E (end)
# Ctrl+W to nuke the last word, Ctrl+U to nuke to start
# !! to rerun, sudo !! to rerun with sudo
history 빠르게 뒤지기·bash
# Press Ctrl+R, type any substring of a previous command
# Press Ctrl+R again to walk earlier matches
# Press Enter to run, Esc/Ctrl+G to abort
# Or grep history directly
history | grep ssh

External links

Exercise

긴 command 한 줄 치고 실행은 보류. 연습: Ctrl+A, Ctrl+E, Ctrl+W (반복), Ctrl+U, Ctrl+Y. 그 다음 command 몇 개 돌리고 Ctrl+R 로 history 검색. .zshrcstty -ixon 추가해서 Ctrl+S 가 터미널 얼리는 거 차단.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.