| Keybinding | Action |
|---|---|
| Alt + f/b | Move cursor to previous/next word |
| Ctrl + a/e | Move cursor to beginning/end of command |
| Ctrl + xx | Toggle between the start of line and current cursor position |
| Keybinding | Action |
|---|---|
Alt + . or !$ |
Previous commands last argument |
| Alt + c | Capitalize word |
| Alt + d | Delete next word |
| Alt + Del | Delete previous word |
| Alt + l/u | Lowercase/Uppercase word |
| Alt + r | Cancel the changes, revert |
| Alt + t | Swap current word with previous |
| Alt + w | Delete until beginning (zsh) |
| Ctrl + _ | Undo |
| Ctrl + k | Cut till end |
| Ctrl + t | Swap the last two characters before the cursor |
| Ctrl + u | Delete whole line (zsh)/ cut until beginning (bash) |
| Ctrl + w | Cut previous word |
| Ctrl + x,e | Open command in editor |
| Ctrl + y | Paste |
| Esc + t | Swap the last two words before the cursor |
!* |
All arguments of previous command |
| Keybinding | Action |
|---|---|
| Ctrl + c | Interrupt/Kill |
| Ctrl + d | Close current shell |
| Ctrl + l | Clear screen |
| Ctrl + z | Background/Foreground job |
| Keybinding | Action |
|---|---|
| Ctrl + r | History search |
| Ctrl + s | Go back to the next most recent command |
^abc^def |
Run previous command, replacing abc with def |
| Keybinding | Action |
|---|---|
| Ctrl + x,v | vi mode (zsh) |
bindkey -e |
Emacs mode |
set -o vi / bindkey -v |
Vi mode |
I'd like to add how to get to the previous COMMAND .
Sure,
Ctrl+atakes me to the beginning of the line,Ctrl+ptakes me to the previous line,but having a 100 line long command, none of the above helps me much in getting to the previous command easily.
It seems like:
ESC+<goes back to the actual beginning of the command buffer for zsh (or the first line of history if already at start of command), andESC+>likewise goes to the end.So to get to the previous command in a 100-line command case, use
ESC+<,Ctrl+pinstead of 100 xCtrl+pFeel free to verify that the same holds true for bash, anyone. :)