Keyboard shortcuts are precious when using the shell. I've listed some of my favorites, but this list is incomplete (to say the least). If you have already mastered the shortcuts that I've listed, then the next step is to read: man bashThe man[ual] page for the bash shell doesn't specify the ' alt' or ' option' key, it instead refers to ' mod' or modifier key. This article describes the modifier key behavior for Macs. Linux and Windows uses the 'alt' key in most cases. Also, note that the man page for bash refers to ' rubout'; this is the ' <-- Backspace' key for PC-based systems and ' delete' on Macs.
| Navigation |
| CTRL + a |
Move to beginning of line |
| CTRL + e |
Move to the end of line |
| CTRL + f |
Move forward a character |
| CTRL + b |
Move back a character |
| MOD + f |
Move forward to the end of the next word |
| MOD + b |
Move back to the beginning of the current or previous word |
|
|
| Edit |
| CTRL + x |
Kill text from cursor to the beginning of line |
| CTRL + k |
Kill text from cursor to the end of the line |
| MOD + d |
Kill word from cursor to the end of the curent word |
| MOD + rubout |
Kill word behind cursor |
CTRL + MOD + y
|
Yank (paste) the first argument from the previous command |
| CTRL + MOD + . |
Yank the last word of the previous command (steps through history) |
| CTRL + u |
Undo |
|
|
| History |
| Up Arrow |
Step upwards through the command history (previously executed commands) |
| Down Arrow |
Step back down through the shell command history |
| MOD + < |
Move to the first line of history |
| MOD + > |
Move to the line being currently edited |
|
|
|