Keyboard shortcuts
Bash and zsh use readline
to get user input.
readline
has a ton of shortcuts to quickly navigate the CLI, but I always forget them so I'm documenting them here for quick reference.
I've omitted shortcuts that I don't currently find useful.
To use ⌥
as Alt
/Meta
in iTerm2 (macOS), set Profiles > Keys > Left option key to Esc+
. This means that when ⌥
is pressed, iTerm2 sends the Esc
(0x80
) key, which indicates to the terminal that the Alt
/Meta
was pressed.
- Moving
- Line level
^E
: go to end of line^A
: go to start of line
- Word level
⌥F
: move forward on word⌥B
: move back one word
- Line level
- Editing
- Line level
^K
: delete from cursor the rest of the line^U
: delete from start of the line to cursor
- Word level
⌥D
: delete from cursor to end of word^W
: delete from start of word to cursor
- Line level