Post

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.

MovementKeymap
Move to start of lineCtrl + a
Move to end of lineCtrl + e
Move one word forwardAlt + f or Alt + <Right>
Move one word backwardAlt + b or Alt + <Left>
Move to first occurrence of “x”Ctrl + ] + x
Move to previous occurrence of “x”Alt + Ctrl + ] + x
Text EditingKeymap
Cut from cursor to start of lineCtrl + u
Cut from cursor to end of lineCtrl + k
Cut the word before the cursorCtrl + w
Cut the word after the cursorAlt + d
Paste deleted content into terminalCtrl + y
Open current command in $EDITORCtrl + x + e

Notes:

  • Cut operations copy to the terminal clipboard (e.g. use Ctrl + y to paste), which means it does not overwrite what is on your system clipboard!
  • Add export EDITOR="nvim" to your ~/.bashrc to make Neovim your default terminal editor
CommandsKeymap
Show your last commandCtrl + p or <Up>
Show your next commandCtrl + n or <Down>
Auto-complete your commandTab
List all possible auto-complete commandsTab Tab
Reverse-i-search for a previous commandCtrl + r
Cancel commandCtrl + c
Clear the screenCtrl + l
Exit the terminalCtrl + 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.

MiscellaneousKeymap
Reattach to suspended processfg
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.

Trending Tags