paint-brush
Become The Shortcut Master — The Mac and Terminal (Part 1)by@pyan
1,472 reads
1,472 reads

Become The Shortcut Master — The Mac and Terminal (Part 1)

by Puyan WeiApril 8th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

I’ve kinda wanted to write this post for a while, mainly because I am anticipating that my trusty 2011 Macbook Air is going to die at any second now. I did replace the old batteries which made it die at 30% charge, and now the replacement is saying I need to change it again…

Companies Mentioned

Mention Thumbnail
Mention Thumbnail

Coin Mentioned

Mention Thumbnail
featured image - Become The Shortcut Master — The Mac and Terminal (Part 1)
Puyan Wei HackerNoon profile picture

I’ve kinda wanted to write this post for a while, mainly because I am anticipating that my trusty 2011 Macbook Air is going to die at any second now. I did replace the old batteries which made it die at 30% charge, and now the replacement is saying I need to change it again…

OPTIMISATION ADDICT

I am an addict. I just can’t help myself by trying to improving things all the time. Its always on my mind. This can be great when it works out, but most of the time its quite an annoying distraction. Like literally yesterday for no real reason I decided to switch up my furniture in my room which took hours, when I had already listed out some other stuff to do that day.

How much time could you save using keyboard shortcuts? Also, you would look cool and get extra swag points! :P

When it comes to coding or just generally working on the computer, some of these optimisations are worth it especially if you are gonna use these actions a lot. Things like learning to touch type really can save you a crap ton of time, and it pains me to see the older generations use their two forefingers to p-r-e-s-s [looks at screen to check for spelling mistakes] e-a-c-h [looks again] l-e-t-e-r [looks and sees error, deletes whole word and starts again].

When it comes to Macs it has taken me some time to decide whether I should use the swiping desktop motion or not. In the end I’ve decided its just not for me, I found that I would open like 3 or 4 different Chrome browsers, each one having 20 tabs and just a bit mad trying to keep track of what goes where…

So right now, Apple + Tab is what I’m using, trying to keep the minimum amount of desktops. But we’ll see how it goes, coz at work I can definitely see that there are moments when multiple screens are a necessity.

It also helps that my left hand is almost always on the apple key, and most of the shortcuts can be done using the left hand, with the touch pad being close to my thumbs. This actually makes things faster then using the mouse gestures and/or setting the corners of your screen to switch tabs in expose.

Using custom keyboard shortcuts whilst playing my poker games! Really me back in the day!

I remember the days of playing 18 tables at once in online poker, and/or also loving playing Starcraft 2 having super high APM but really not being that good at the game at all, since it was mostly spam and not useful commands! I think my bias might come from the fact that when you keep switching windows using shortcuts it looks pretty cool and looking cool and imagining you’re some cool cybernetic futuristic hacker always trumps everything else! (I’m kidding :P).

MAKE IT A HABIT!

Using shortcuts can be difficult but it will pay off later on, so its important that you make yourself do it. With the touch typing I basically made myself type without looking at the keyboard by forcing myself to do it during the msn messenger years (who remembers that? Ok, calm down AOL users yeah yeah u guys where even older…). Even though my typing isn’t perfect “five finger” official style, (I use forefingers to hit space bar), I still learned my own method of allowing myself to touch type which is super useful.

Starcraft 2 players were notorious for having high APM (Actions Per Minute) to control a huge number of things during their gameplay.

That being said, when introducing yourself to new optimisations, remember to add things little by little, otherwise it will be too overwhelming. Do things Agile style!

BAD MAC KEY NAMINGZ

A quick note about the Apple Key. I think officially Apple wants people to call this this Command Key, but for some reason they keep the Apple squarey circular corner symbol around. If that’s the case I don’t know why they keep it around, either have one or the other.

I prefer saying Apple key because Command is not only similar to the word Control, but Command and Control are literally next to each other bar one key.

The Apple Key symbolized by the Apple logo, or that curly square, AKA The Option Key… not confusing at all lol

That key is called the Alt Key but even more stupidly is also known as the Option Key, which is not printed on the key, just some weird two to one lane road symbol is.

When it comes to trying to make things as least confusing as possible for non techy users, they really messed up and for some reason are sticking to it.

Just for our sakes, I’m gonna use Apple Key and Alt Key.

THE MAC

Undo It [Apple + Z], Redo It [Apple + Y] — Most Apple programs will have this as their defaults. This is great as it should help you not being too scared of trying things out knowing you can always roll back and/or re-re roll back. Its the best way to learn! Gone are the days of the old skool computers where one wrong command could cause a major wide crash (i.e my Dad’s old 8 inch floppy disk computer).

Switching Windows [Apple + Tab]/[Apple + Backtick] — Note that is not an single quote mark, this is a backtick which is the key that you've never seen or used until now between left shift and z. This is great for if you have multiple browser windows or Atom coding windows and don't want to merge them together, but still manage to quickly switch between them. Unfortunately using the backtick symbol here is messing with the medium editing so I cannot actually show it here.

Alt Tabbing combined with Alt Backticking! Honestly, how is Yahoo surviving I literally don’t know anyone who uses it!

WhereTF is the Delete [fn + Backspace or Control + D] and the # key[Alt + 3]? — One of the most common complaints I hear about using macs is they do miss out on a few keys. Deleting is pretty common in Windows, which is like a reverse backspacing way to delete a word. This can be done using the function key which is the most bottom left key and backspace, or control + D.

For some reason Apple hates twitter, so even though on windows this is on the main keyboard, on the mac this doesn’t even make a shift key cut! Again, having these different assignments to control, apple key, function key and alt key makes it all the more confusing for new users.

Bin It with [Apple + Backspace] — Sometimes files need to be deleted asap. Box a bunch of your items with the mouse and hit that shortcut for maximum time saving with that satisfying binned sound.

Search It with [Apple + Spacebar] — Apple’s search bar can be pretty quick, espcially since your hands are on the keyboard already. Just hit Apple + Spacebar and type your folder/file/app and you’ll open it in no time.

THE TERMINAL

I’d suggest using iTerm2 as your terminal and then modding it following this blog post.

This also will allow cool functionality like tabbing through your files once you start typing a name, it will try and guess it, meaning no more need to type ‘cd’.

This page is awesome to find shortcuts for the terminal.

Go to Start [Control + A / Function + Left Arrow] or End [Control + E / Function Right Arrow] of sentence — During my course at Makers, one of the most common things I’d see us all doing in the terminal was writing out a long sentence (usually a commit message), then realising there was a typo and then having to use the curser to move it back to the beginning. You couldn’t use the mouse to jump there, which was really annoying. Damn, all it took was a few seconds of googling it…

The ZSH shell allows you to use shortcuts for git. This can save you a lot of time, since as high quality coders we’re always gitting our code, right?? ;)

Blue colours show where you currently are, yellow/green show you git status and what branches your working on!

Common ones I use are;

  • Git Add All — gaa
  • Git Commit Message — gcm [message]
  • Git Push — gp
  • Chain the 3 above, if one fails then others will stop — gaa && gcm [message] && gp
  • Git Status in lovely colours — gss
  • Git Create Branch — gcb [branch name]
  • Git See All Branches — gba
  • Git Pull — gl
  • Git Pull from Brance — ggl [branch name]

I’ve messed around a lot with where to put my terminal, at first I put it in another screen to swipe to, then I’ve been playing around with setting a position on the right and then bottom permanently. However, my work colleague showed me this pretty awesome blog post about how to make it pop up (or down if you prefer) using a hotkey (I used Control + Spacebar).

The terminal pops up and then slides downwards when and only when you need it!

I know there is an option to find a package in Atom which puts your terminal at the bottom, but I like my custom ZSH iTerm2 window not just because of the ZSH shortcuts but also the fact that it will show you your git statuses bright and clearly which I really want.

Next week— Chrome and Atom Shortcuts. Have a great week y’all and now enjoy the confusion of some code bizarreness! — https://www.destroyallsoftware.com/talks/wat