(Thanks to @oaktree for giving me an idea to start this topic. )
Most of us spend a lot of time in some type of a shell. To save time (and sometimes sanity) it is useful to know some (keyboard) shortcuts which can be pretty darn useful.
So if you know a useful shortcut, and it isn’t already mentioned, drop it below.
Notes:
- ^ is a shorthand for CTRL (control)
- all shortcuts should work in bash, but are generally shell agnostic (i.e., most will work in other shells, like Cisco iOS)
My most useful shortcuts:
- ^L = clear; clear the screen of the shell (emulator)
- ^SHIFT C & ^SHIFT V = copy & paste
- SHIFT INS = paste
- ^W = delete the word before the cursor
- word1 word2| word3 > will delete word2
- ALT D = delete the word after the cursor
- word1 |word2 word3 > will delete word2
- ^U = delete from cursor to the beginning of the line
- word1 word2| word3 > will delete word2, word1
- ^A = jump to the beginning of the line (like HOME)
- ^E = jump to the end of the line (like END)
- ^LEFT | ^RIGHT = jump between words
- ^P = scroll through history, from oldest to newest (like UP)
- ^F = move cursor one char to the right
- ^H = delete one char behind the cursor
- ^D = delete one char under the cursor
- ^O = execute command
- ^C = terminate running command
- ^Z = pause running command, return to stdin
- bg = push paused command to background, resume execution (watch out, command will print to stdout if not otherwise specified)
- fg = pull paused / backgrounded command ‘to front’, resume execution if paused
- ^r = search command history
- additional ^r = scroll through search results