Skip to content

Instantly share code, notes, and snippets.

@bucker
Last active May 16, 2021 17:31
Show Gist options
  • Save bucker/69ba5d061116c4cc981d to your computer and use it in GitHub Desktop.
Save bucker/69ba5d061116c4cc981d to your computer and use it in GitHub Desktop.
Bash shortcuts for Mac
To Use the option (⌥) key, set it as meta key
## Moving the cursor
* `⌃a`: Go to the beginning of the line
* `⌃e`: Go to the end of the line
* `⌃p`: Previous command (Up arrow)
* `⌃n`: Next command (Down arrow)
* `⌃f`: Forward one character
* `⌃b`: Backward one character
* `⌃xx`: Toggle between the start of line and current cursor position
* `⌥f`: Forward one word
* `⌥b`: Backward one word
## Editing
* `⌃L`: Clear the screen, similar to the `clear` command
* `⌥Del`: Delete the word before the cursor
* `⌥d`: Delete the word after the cursor
* `⌃d`: Delete character under the cursor
* `⌃w`: Cut the word before the cursor to the clipboard
* `⌃k`: Cut the line after the cursor to the clipboard
* `⌃u`: Cut/delete the line before the cursor position
* `⌃y`: Paste (yank)
* `⌥t`: Swap current word with previous
* `⌃t`: Swap the last two characters before the cursor
* `Esc + t`: Swap the last two words before the cursor
* `⌥u`: UPPER capitalize every character from the cursor to the end of the current word
* `⌥c`: Capitalize the character under the cursor and move to the end of the word
* `⌃-`: Undo
## History
* `⌃r`: Recall the last command including the specified character(s) searches the command history as you type. Equivalent to : vim ~/.bash_history
* `⌃p`: Previous command
* `⌃n`: Next command in history
* `⌥.`: Use the last word of the previous command
## Process control
* `⌃c`: Interrupt/Kill running process
* `⌃s`: Stop output to the screen (for long running verbose commands)
* `⌃q`: Allow output to the screen
* `⌃d`: Send an EOF marker, unless disabled by an option, this will close the current shell
* `⌃z`: Send th signal SIGTSTP to the current task, which suspends it. To return to it later enter `fg 'process name'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment