Shell Configuration and ProductivityLesson 3.5
How to use shell history and keyboard shortcuts to work faster
Ctrl+R reverse search, history command, !! last command, !$ last argument, Ctrl+A and Ctrl+E, Ctrl+L, Ctrl+U, HISTSIZE, HISTFILESIZE
Shell History and Keyboard Shortcuts
Power users rarely retype commands. Shell history and a handful of keyboard shortcuts make most repetitive terminal work disappear.
Reverse search with Ctrl+R
# Press Ctrl+R, then start typing part of a previous command
# Press Enter to run, or Ctrl+R again for the previous matchHistory shortcuts
history # list last 500 commands with numbers
!42 # run command number 42 from history
!! # run the last command again
sudo !! # re-run last command with sudo
!$ # last argument of the previous commandCursor movement shortcuts
Ctrl+A # jump to start of line
Ctrl+E # jump to end of line
Ctrl+W # delete word before cursor
Ctrl+U # delete entire line before cursor
Ctrl+L # clear screen
Alt+F # jump forward one word
Alt+B # jump backward one wordConfiguring history size
export HISTSIZE=10000
export HISTFILESIZE=20000These defaults are small on many distros. Increasing them means you can find commands from weeks ago with Ctrl+R.
