firedev.com

Mac as IDE: You're using it wrong

Are you using this editor and that version control app? Think bigger. Instead of jumping between applications or forcing yourself to an IDE use your Mac as a system where apps work together for the greater good.

The main idea is to use your environment as a single entity rather that a collection of various application. Let me show you some tricks that help me do the job. Basically it boils down to some simple concepts:

  • Control everything from the keyboard.
  • Limit distractions.
  • Have a system behind the madness.

I control everything from keyboard: apps, windows. Is it faster and less distracting if you don’t have to reach for mouse. And this is something Windows got right. Mac forces you to use mouse more often. It’s not that much of a problem if you are on Macbook. Trackpad is always within the reach, but still, things could be better. Let’s fix them.

Keyboard Control

First turn Full Keyboard Access to Full Control in Keyboard > Shortcuts pane of System Preferences. Now we can switch between buttons and click checkboxes in pop-up windows from keyboard. Not everybody knows that you can use Cmd-First letter of the button in popup as well. So you can press Cmd-D to choose Don't Save in Save Dialog.

Enable function keys to be used as such. You will have to press Fn along with brightness and volume control but that will allow you easier reach for the Menu bar we will hide next.

Function Keys

Hide dock with Cmd-Opt-D and the menu bar in General > Automatically hide and show menu bar. El Capitan allows us to use almost the whole screen estate apart from the tiny bar at the edge of the screen where hidden Dock is located. To quickly access Menu or to have a peek at the current time you can use Ctrl-F2 or Cmd-?. The help shortcut Cmd-? or Cmd-Shift-/ opens help menu from which you can search and execute menu items available in the app.

Full Keyboard Access

Additional shortcut to remember are: Ctrl-F8 to reach application icons in Menu if you need them. And, maybe, Ctrl-F7 to toggle keyboard control back on if you accidentally disable it.

Finder

Learn Finder’s Go menu shortcuts. It will save you a ton of time and if you are using Cmd-Shift-G to switch to a folder you can autocomplete paths using Tab. I use Documents, Desktop, Download and Connect to Server shortcuts all the time.

Finder Go Menu

And don’t forget you can switch views in Finder with Cmd-Numbers. However I don’t think I am using anything other than Cmd-1 (Icons) and Cmd-2 (List).

In other apps like Chrome or iTerm you can use Cmd-Numbers to quickly switch tabs.

Zoom

Another semi-hidden option in OS X is full-screen zoom. Enable it in Acessibility > Use scroll gesture to zoom. Leave the keyboard modifier as Ctrl and make sure Zoom Style is set to Fullscreen Zoom. Now you can zoom in and out by scrolling while holding Ctrl. This is very useful if you need to make sure the pixels are in place or to show something to a person across the room.

Keyboard Zoom

Don’t forget to disable Smooth images as it blurs the zoomed in image and you can’t see individual pixels clearly.

Karabiner and Seil

I use these two tiny utilities by the same developer for additional keyboard tricks.

Karabiner takes care of switching layouts for me. I don’t switch between layouts, I just press Left Shift for English and Right Shift for Russian. So before writing code I just hit Left Shift and I am sure I am using English. This is it.

Being a Vim user I have Caps Lock mapped to Ctrl in Keyboard. Seil adds additional mapping to Caps Lock so it serves both as Ctrl when held and as Esc when hit once.

Window Management

I don’t minimize. I find this annoying. If there is too much clutter I simply hide either the current app via system shortcut Cmd-H or hide everything else via Cmd-Opt-H (Hide Others). Some apps might need Cmd-0 to show main window after gaining focus again. If anything did not show up you can check in Menu > Window for the Show Main Window shortcut for the given app.

SizeUp

To control windows I am using SizeUp. It allows me to size windows to half, quarter, and full-screen. I move windows between screens and center them so I can see a little bit behind around the edges of the screen. There are many like it, but this one is the best tool for the job as I can do everything without lifting hands from keyboard.

SizeUp Shortcuts

I am a bit biased partly because of the involvement in development process (Hi, Steve). But mostly because SizeUp out-of-the box comes with the most settings I agree with. The only thing I am not content with is up arrow pointing to the upper right corner. I still think it should be the upper left.

The only setting I change is 90x90% size for the Center Window and maybe disabling Move to Space shortcuts.

Check their website for other tiny window management apps that offer slightly different ways.

###BetterTouchTool

And of course BetterTouchTool. This app is indispensable. Without it the Trackpad would be only half as useful.

First thing to do is to free three-finger-swipes left and right for BTT. Open Trackpad Preference Pane and change Swipe between full-screen apps to Swipe with four fingers

Now we can put them to good use to switch between tabs for all applications.

BetterTouchTool

Some apps require special treatment so you would have to add them separately. For instance I have Cmd-Shift-[ and Cmd-Shift-] mapped for Safari.

It might be a bit tedious and I wish it had Dropbox sync. BTT can replace SizeUp since it can do almost everything SizeUp does if not all. But entering a dozen of shortcuts is not very fun task. This is why I am still using these two apps together.

Another free and open-source alternative to SizeUp: Spectacle. It overrides almost system-wide shortcuts Cmd-Opt-Arrows that are used to switch tabs in most applications. So if you are using it with BTT you will have to do some additional fine-tuning.

BetterTouchTool also adds window snapping akin to Windows’ AeroSnap which is pretty nice when you are feeling too lazy to reach the keyboard. Just drag a window to a screen edge or into the corner and it gets resized accordingly.

Usually I am putting windows side-by-side on a single screen. When I had two monitors that were big enough and could be rotated vertically splitting each in two part gave me four almost “virtual” screens.

None of these apps have Menu or Dock icons enabled. I am not the most organized or efficient person so I hide and disable everything to limit distractions and have tidier screen. If you need to access setting - launch the app again.

###EyeFriendly

When there is not enough space on a single screen I launch EyeFriendly. It has only two shortcuts assigned that allow me to switch resolutions up and down. This is really useful if I need to see what site I am working on looks like in bigger resolution. Or if there is not enough space to put two apps side by side comfortably.

EyeFriendly

##App Switching

As it is the case with keyboard layouts instead of switching between apps I am switching straight into the app I need. That makes the computer feel as a whole. I have identified the apps I use most and assigned shortcuts for them. I have tried every Shortcut app imaginable, but only one supported Dropbox sync out-of-the box.

###Alfred

For many the trusty butler serves as replacement for Spotlight. And I do occasional GitHub searches from it as well. But other than that I find Spotlight pretty adequate. Alfred has another important functionality sadly available only in pricey PowerPack – Workflows.

Workflows

I have tried different key combos and I think Cmd-Ctrl works best. So here are the mnemonics

  • Cmd-Ctrl-B — Browser (Chrome)
  • Cmd-Ctrl-G — Git (gitx-dev)
  • Cmd-Ctrl-OOmniFocus
  • Cmd-Ctrl-T — Terminal (iTerm)
  • Cmd-Ctrl-Q — SQL (Sequel Pro)
  • Cmd-Ctrl-Z — Messages. Kind of like Un-Do, get it?
  • Cmd-Opt-Ctrl-~12345 — To rate music in iTunes

And Space which is much too powerful is also my leader key in Vim and I control Tmux with Ctrl-Space:

  • Cmd-Ctrl-Space — Finder
  • Cmd-Shift-SpaceDash
  • Cmd-Opt-Ctrl-Space — Alfred, it can’t go unassigned and I do occasional GitHub searches

You know you can press outlined buttons in modal dialogs with Space, and preview files in Finder without opening them, right?

Here is a version of the App Shortcuts Workflow that comes preloaded with some variants of apps (Sublime/Atom, iTerm/Terminal, Chrome/Safari) you can use to build your own system.

Some other shortcuts are defined inside the apps that use them. I was experimenting with double assignments so Alfred launches as app and then the same shortcut activates the app function but it turned out to be not very reliable. So I have some shortcuts defined in the apps that are either auto-started like NVAlt or that I use from time to time like Sip or ColorSnapper before that:

  • Cmd-Ctrl-C — Color (Sip/ColorSnapper)
  • Cmd-Ctrl-L — Notational veLocity (NVAlt), too bad it’s not updated anymore.
  • Cmd-Esc — iTerm again. This one toggles full screen terminal window.

I have also had mappings for Textmate, Sublime and Atom, while trying to use them. Switched to Vim since so everything is happening in terminal. I am using iTerm with General > Lion Style Fullscreen disabled. After that I can use Cmd-Enter for true fullscreen mode I wish other apps had.

Bonus

Here’s a cool trick that allows me to refresh Chrome without leaving the editor. I have another shortcut in Alfred Cmd-Opt-R (that has a nice system-wide ring to it). It launches this piece of AppleScript:

on alfred_script(q)
  tell application "Google Chrome"
    reload active tab of (get window 1)
  end tell
end alfred_script

This little piece of code refreshes the current window in Google Chrome so you don’t have to switch focus.

It is especially useful if you have two screens so you can use one for editing and refresh browser in another.

Conlusion

I hope that gives the idea how everything is tied together. I jump from Mail to Terminal, git fetch, edit, jump to GitX, review changes, jump to browser, open two apps side-by-side, edit in one window, see changes in another…

This approach also give you some modularity. If you don’t like GitX, change it to SourceTree. Don’t like Sublime, change to Atom. You can replace and fine tune individual parts of the system but still be sure when you press Cmd-Ctrl-T you get to the terminal. Be it iTerm or Terminal or I don’t know what else.

So this is the staples of my day-to-day process. Please let me know if you found anything useful and share some of your tricks.