Skip to content

Instantly share code, notes, and snippets.

@wyudong
Created June 27, 2016 03:16
Show Gist options
  • Save wyudong/5483b0d6cf54de0e2e37d0e88026715b to your computer and use it in GitHub Desktop.
Save wyudong/5483b0d6cf54de0e2e37d0e88026715b to your computer and use it in GitHub Desktop.
Useful commands and shortcuts for terminal

Mac Terminal Cheatsheet

Moving cursor

Command Description
control + a Go to the start of the line
control + e Go to the end of the line
control + b Move cursor one character backward
control + f Move cursor one character forward
alt + b Move cursor one word backward
alt + f Move cursor one word forward
alt + ← Same as alt + b
alt + → Same as alt + f

Cut, delete and paste

Command Description
alt + delete Cut the word before cursor
alt + d Cut the word after cursor
control + w Same as alt + delete
control + u Cut the Line before cursor
control + k Cut the Line after cursor
control + y Paste the last thing to be cut
control + l Clear the screen

Other useful shortcuts

Command Description
tab Auto complete file or directory names
control + c Kill whatever you are running
control + d Exit the current shell
control + t Swap the last two characters before cursor
alt + . Use the last word of previous command
alt + # Comment current command

Comments

  • Enable Use Option as Meta key in Terminal > Preferences > Profiles > Keyboard in order to use some commands involved with alt.

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment