Terminal Cheatsheet
This is my cheatsheet for the bash terminal.
Cheatsheet
Default Keymaps
I haven’t shown all keymaps - these are just the ones I use.
| Movement | Keymap |
|---|---|
| Move to start of line | Ctrl + a |
| Move to end of line | Ctrl + e |
| Move one word forward | Alt + f or Alt + <Right> |
| Move one word backward | Alt + b or Alt + <Left> |
| Move to first occurrence of “x” | Ctrl + ] + x |
| Move to previous occurrence of “x” | Alt + Ctrl + ] + x |
| Text Editing | Keymap |
|---|---|
| Cut from cursor to start of line | Ctrl + u |
| Cut from cursor to end of line | Ctrl + k |
| Cut the word before the cursor | Ctrl + w |
| Cut the word after the cursor | Alt + d |
| Paste deleted content into terminal | Ctrl + y |
Open current command in $EDITOR | Ctrl + x + e |
Notes:
- Cut operations copy to the terminal clipboard (e.g. use
Ctrl + yto paste), which means it does not overwrite what is on your system clipboard! - Add
export EDITOR="nvim"to your~/.bashrcto make Neovim your default terminal editor
| Commands | Keymap |
|---|---|
| Show your last command | Ctrl + p or <Up> |
| Show your next command | Ctrl + n or <Down> |
| Auto-complete your command | Tab |
| List all possible auto-complete commands | Tab Tab |
| Reverse-i-search for a previous command | Ctrl + r |
| Cancel command | Ctrl + c |
| Clear the screen | Ctrl + l |
| Exit the terminal | Ctrl + d |
| Suspend current process (e.g. Neovim) | Ctrl + z |
Other tricks
Here are some other terminal tricks I like to use - type these into the terminal.
| Miscellaneous | Keymap |
|---|---|
| Reattach to suspended process | fg |
| Repeat last command | !! |
| Repeat last command but exclude first word | !* |
Note: !! can be useful if you forget to run your command with sudo (e.g. sudo !!).
This post is licensed under CC BY 4.0 by the author.