Bash Keystrokes – Mosky’s Notes
Moving
| Left | Up | Right | Down |
Character | C-b* | C-f* |
Alphanumeric Word | M-b (M-C-b**) | M-f (M-C-f**) |
Within Line | C-a* | C-e* |
Line | C-p* | C-n* |
- *: macOS supports in the ABC input source.
- **: macOS supports, but Bash doesn't.
- In macOS, you can add <Shift> to select text.
- In iTerm, use <Option> as <Meta> by configuring “Profiles / Keys / * Opt Key / Esc+”.
Deleting or Killing
| Left | Right |
Character | ^H (= C-h*) | C-d* |
Alphanumeric Word | M-Rubout* (= M-C-h) | M-d |
Space Word | C-w | |
Within Line | C-u | C-k* |
- C-y*: yank (paste).
- M-y: rotate the kill ring (yank ring), and yank, only works after <C-y> or <M-y>.
- C-/: undo.
- <M-Rubout> = <Option-Delete> on Mac.
- *: macOS supports in the ABC input source.
History Manipulation
| Up | Down |
Fetch | C-p | C-n |
Search | C-r | C-s |
- <C-s> needs `$ stty -ixon`.
- <C-r> & <C-s> are useful with tag comments like `$ <a long long command> #TAG` and then `$ <C-r>#TAG`.
Miscellaneous
- C-l: clear the screen.
- C-x C-e: edit command in an editor.
- C-v TAB: insert a tab.
- M-u: uppercase the word.
- M-l: lowercase the word.
Not Bash's, but Work Closely
Signals
- Ctrl-C: SIGINT, signal interrupt.
- Ctrl-Z: SIGTSTP, signal terminal stop.
- Ctrl-\: SIGQUIT, signal quit.