Zsh#
The Z shell. Zsh ships its own line editor (ZLE) instead of GNU
readline, but the default emacs keymap is binding-compatible
with bash so the muscle memory carries over. bindkey -v
switches to vi mode; bindkey -e returns to emacs. bindkey
with no arguments lists every active binding in the current
keymap; bindkey -l lists the keymaps themselves
(emacs, vicmd, viins, main, isearch,
command, menuselect).
For shell startup files, completion configuration, and history options, see Zsh.
Cursor Movement#
Key |
Action |
|---|---|
|
move to start of line ( |
|
move to end of line ( |
|
move back one character |
|
move forward one character |
|
move back one word |
|
move forward one word |
|
jump between current position and mark |
Editing#
Key |
Action |
|---|---|
|
delete character under cursor (EOF on empty line) |
|
delete character before cursor |
|
delete character before cursor |
|
delete word forward |
|
delete word backward |
|
delete word backward (alphanumeric-aware) |
|
kill to end of line |
|
kill whole line (zsh default; bash kills to start) |
|
yank (paste) last killed text |
|
cycle through previous yanks after Ctrl-y |
|
transpose character with previous |
|
transpose word with previous |
|
uppercase word from cursor |
|
lowercase word from cursor |
|
capitalize word from cursor |
|
set mark |
|
undo |
|
undo (alternative) |
History#
Key |
Action |
|---|---|
|
previous command ( |
|
next command ( |
|
incremental reverse search |
|
incremental forward search (requires |
|
abort current search, restore line |
|
history search backward on current prefix |
|
history search forward on current prefix |
|
insert last argument of previous command |
|
cycle through previous-command last-args after Alt-. |
|
run previous command |
|
last argument of previous command |
|
first argument of previous command |
|
all arguments of previous command |
|
run history entry N |
|
run most recent command starting with <string> |
|
rerun previous command, substituting old for new |
|
list recent history entries |
|
re-edit history entry N in |
Process Control#
Key |
Action |
|---|---|
|
send SIGINT to foreground process |
|
suspend foreground process (SIGTSTP) |
|
send EOF (close stdin); exit shell on empty line |
|
clear screen |
|
pause terminal output (XOFF) |
|
resume terminal output (XON) |
|
send SIGQUIT to foreground process (core dump) |
Completion#
Zsh completion (loaded by autoload -Uz compinit && compinit)
is the headline feature. Tab cycles through matches in menu
mode; Shift-Tab reverses.
Key |
Action |
|---|---|
|
complete / cycle next match |
|
cycle previous match |
|
list all completions |
|
show possible completions without inserting |
|
insert all completions |
|
try filename completion explicitly |
|
username completion |
|
variable completion |
|
hostname completion |
|
complete command-line argument (positional) |
|
complete environment variable inline |
|
list expansions of a glob pattern |
|
expand a tilde at cursor |
|
show what completion would do (debug) |
ZLE Specials#
Zsh-only Line Editor widgets and bindings that bash does not ship.
Key |
Action |
|---|---|
|
push current line onto stack, get fresh prompt; auto-restored after next command |
|
run |
|
edit current line in |
|
same as Ctrl-x Ctrl-e |
|
swap to vi-command keymap for one keystroke |
|
expand a glob in place |
|
expand parameter / command substitution in place |
|
expand alias at cursor |
|
history-incremental-search-backward (alt binding) |
|
undo |
|
history-expand-line; preview |
|
history-incremental-pattern-search-backward (with PCRE-style globs) |
Vi Mode#
Enable with bindkey -v or set -o vi. Two keymaps:
viins (insert) and vicmd (command). Esc switches
from insert to command; in command mode the standard Vim motions
apply.
Key |
Action |
|---|---|
|
enter command mode ( |
|
insert at cursor |
|
append after cursor |
|
append at end of line |
|
insert at start of line |
|
move to start of line / first non-blank |
|
move to end of line |
|
word forward / backward |
|
end of word forward |
|
find next / previous occurrence of char |
|
delete character under cursor |
|
delete word / to end of line / whole line |
|
change word / to end of line / whole line |
|
yank word / to end of line / whole line |
|
paste after / before cursor |
|
undo |
|
redo (in |
|
open current line in |
|
previous / next history line ( |
|
history search backward / forward |
Misc#
Key / Command |
Action |
|---|---|
|
undo last edit |
|
newline / accept line |
|
insert next key literally (raw escape sequence) |
|
switch editing mode for this session |
|
list every active binding |
|
list keymaps |
|
bind a key to a widget in a specific keymap |
|
list every widget name |
|
find the key bound to a widget |
|
list terminal-driver shortcuts ( |