Mac Terminal Shortcuts

It does always come as a surprise to me how uncomfortable the terminal is to a lot of developers – especially people who move from Windows to Mac/Linux. I’m just putting out a (small) list of keyboard shortcuts that could make your life on a Mac terminal so much better. This won’t make you a command line ninja, but if you’re too busy to learn the command line thoroughly but still would like to be decently comfortable using it, this list is for you.

Note: If you’re coming from Windows, be careful to note whether it’s ‘command’ or ‘ctrl’, and the ‘option’ key is the same as the ‘alt’ key.

Moving the Cursor

You can’t ‘edit’ text in a terminal because it’s not a text document, it’s just a log of whatever you executed. Only the current line is relevant for editing. So it doesn’t make sense for the up arrows and down arrows to move the cursor up and down. Inside the current line, the following four things are what you should know –

  • Move the cursor left / right : Left / Right
  • Goto beginning / end of line : Ctrl + A / Ctrl + E
  • Goto previous / next word : Option + Left / Option + Right
  • Move the cursor to a specific location : Option + Left Click

Scrolling the Screen

Scrolling is quite simple using the mouse or the trackpad. But in case you’d like to scroll using the keyboard, remember these –

  • Scroll by lines : Option + Cmd + Page Up / Option + Cmd + Page Down
  • Scroll by pages : Cmd + Page Up / Cmd + Page Down
  • Scroll by commands : Cmd + Up / Cmd + Down
  • Scroll to top / bottom : Page Up / Page Down

Selecting Text

You surely know the normal Click + Drag text selection. Some more ways to select text are –

  • Select a word or a line : Double Click / Triple Click
  • Select a URL or a file path : Shift + Cmd + Double Click
  • Select last command and it’s output : Shift + Cmd + Up
  • Select everything : Cmd + A
  • Deselect : Esc

Deleting Text

Deleting text is straightforward, which you’d do with backspace and/or delete keys. But still I think a few shortcuts are worth remembering –

  • Delete word before cursor : Ctrl + W
  • Delete the entire line : Ctrl + U
  • Delete from cursor to end of line : Ctrl + K
  • Clear Screen : Cmd + K
  • Clear upto previous command : Cmd + L

Switching Tabs

  • Open a new tab : Cmd + T
  • Open a new window : Cmd + N
  • Close current tab : Cmd + W
  • Cycle through tabs : Ctrl + Tab (Hold Shift to cycle in reverse)
  • Cycle through windows : Cmd + ` (Hold Shift to cycle in reverse)
  • Exit terminal completely : Cmd + Q

Other Neat Stuff

  • Input Emojis : Ctrl + Cmd + Space
  • Command History : Up / Down
  • Search History : Ctrl + R
  • Save some text to a file : Select the text and press Shift + Cmd + S

That’s enough shortcuts to make you super fast while working with a terminal. But there are more shortcuts you can learn You can always learn more shortcuts at the official reference – https://support.apple.com/en-in/guide/terminal/trmlshtcts/mac