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 –

About Me

Yup. I just deleted the blog that used to be here. Not that it was a good one, but I had not blogged in it for quite some time and now when I looked at it, it felt like reading someone else’s blog. I’m in a different career now. I was into making reports and dashboards then and now for the last 3 years I’ve returned back to good old programming. I’m a Java developer, creating API services that involve reactive programming, data streams, graph databases and document databases. I like this better. I’d like programming things that involve pictures, animations and sounds even more. But what I do is good.

Then why did I come here and delete the blog that was just sitting there, not harming anyone?

I’ve started feeling like I’m no longer great at my job. I’ve forgotten many old lessons. I’m stuck between being a manager who has to organise tickets, being a leader who has to coach developers, and being a developer who has to be very very good at coding. Juggling between the three is taking a toll, but I don’t think it’s unfair. That’s the trade and I need to get good at it. Also, I’ve lost the habit of doing hobby projects – fun things, coding-related, that have nothing to do with my job. I think those are the ones I learned the most from.

I’ll just be writing whatever I find interesting at that time.