I always forget these shortcuts, and I always spend a couple of minutes on google trying to find the one I need. I’ve decided it’s best to have them here, for personal reference, and for anyone else who might find them useful.
- <Ctrl-u> Clear the line you’re typing
- <Ctrl-r> Search the history by typing letters
- <Ctrl-w> Delete previous word (<Alt+Backspace> Works too)
- <Ctrl-a> Goto beginning of the line
- <Ctrl-e> Goto end of the line
- <Ctrl-b> Move back one character.
- <Alt-b> Move back one word.
- <Ctrl-f> Move forward one character.
- <Alt-f> Move forward one word.
- <Ctrl-]>x Where x is any character, moves the cursor forward to the next occurance of x.
- <Alt-Ctrl-]>x Where x is any character, moves the cursor backwards to the previous occurance of x.
- <Ctrl-t> Swap the character before the cursor
- <Ctrl-l> Clear the screen
- <Ctrl-u> Delete from the cursor to the beginning of the line.
- <Ctrl-k> Delete from the cursor to the end of the line.
- <Ctrl-w> Delete from the cursor to the start of the word.
- <Ctrl-y> Pastes text from the clipboard.
- <Ctrl-l> Clear the screen leaving the current line at the top of the screen.
- <Ctrl-_> Undo the last changes. (<Ctrl-x><Ctrl-u> Does the same)
- <Alt-r> Undo all changes to the line.
- <Alt-Ctrl-e> Expand command line.
- <Ctrl-r> Incremental reverse search of history.
- <Alt-p> Non-incremental reverse search of history.
- <Esc-Del> Delete previous word (may not work, instead try Esc followed by Backspace)
- <Esc>. Take the last argument of the last command
You can also type
$ bind -P
to get the list of the shortcut keys…