Skip to content

Instantly share code, notes, and snippets.

@gargolito
Created September 25, 2019 14:00
Show Gist options
  • Save gargolito/0f5605a6f7983320e2eb1bccbfc3ee26 to your computer and use it in GitHub Desktop.
Save gargolito/0f5605a6f7983320e2eb1bccbfc3ee26 to your computer and use it in GitHub Desktop.
#linux #bash
Command Editing Shortcuts
ctrl+a, ctrl+e Go to the start/end of the command line
ctrl+u, ctrl+k Delete from cursor to the start/end of the command line
ctrl+w, alt+d Delete from cursor to start/end of word (whole word if at the boundary)
ctrl+y Paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
ctrl+xx Move between start of command line and current cursor position (and back again)
alt+b, alt+f Move backward/forward one word (or go to start of word the cursor is currently on)
alt+C Capitalize to end of word starting at cursor (whole word if cursor is at the beginning of word)
alt+u Make uppercase from cursor to end of word
alt+l Make lowercase from cursor to end of word
alt+t Swap current word with previous
ctrl+f, ctrl+B Move forward/backward one character
ctrl+d, ctrl+H Delete character after/before under cursor
ctrl+t Swap character under cursor with the previous one
Command Recall Shortcuts
ctrl+r Search the history backwards
ctrl+g Escape from history searching mode
ctrl+p Previous command in history (i.e., walk back through the command history)
ctrl+n Next command in history (i.e., walk forward through the command history)
alt+. Use the last word of the previous command
Command Control Shortcuts
ctrl+l Clear the screen
ctrl+s Stops the output to the screen (for long running verbose command)
ctrl+q Allow output to the screen (if previously stopped using command above)
ctrl+c Terminate the command
ctrl+z Suspend/stop the command
Bash Bang Shortcuts
!! Run last command
!blah Run the most recent command that starts with blah
!blah:p Print out the command that !blah would run (also adds it as the latest command in the command history
!$ The last word of the previous command (same as alt+.)
!$:p Print out the word that !$ would substitute
!* The previous command except for the first word (e.g., if you type find some_file.txt /, then !* would give you some_file.txt /)
!*:p Print out what !* would substitute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment