The best kittens, technology, and video games blog in the world.

Sunday, February 28, 2016

How to configure OSX 10.11 El Captain for software development

Cats by sokole oko from flickr (CC-NC-ND)

With every new Macbook, I'm updating the guide, previous version is here. A few thing changed - mostly some links which used to work have been taken over by malware. OSX is turning into Windows more and more.

Basics

  • Go to Settings > Security > FireVault, turn on FireVault. This will restart your computer.
  • Install some sensible browser like Chrome or Firefox.
  • Afterwards either sign up into your account on which you hopefully have your AdBlock setup, or install some. Most popular seems to be uBlock Origin these days, but pretty much any of them will do just fine.
  • Install whichever cloud sync service you're using like Dropbox etc. And start syncing your stuff.
  • Install iTerm2 for sensible terminal emulator.
  • Clean up all crap from dock. Other than Launchpad and System Settings, everything else should be gone. Add iTerm2, your browser, and your text editor, and any application you wish to install there instead of stock Apple crap.
  • It's also a good idea to disable Spotlight as soon as possible by running sudo mdutil -i off / - before it tries to index all of your dropbox and generally ruin performance of your machine.

Editor

Install some sensible text editor like Sublime Text (requires license key) or Atom (free, a bit slower).

Whichever editor you choose, you'll definitely need to configure it to your liking.

Then symlink it so you can use it from command line

  mkdir -p ~/bin
 ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl

Settings

Default Mac settings are totally awful, time to fix that.
  • Max brightness
  • Settings > Security > Allow apps downloaded from: > Anywhere
  • Settings > Mouse > Max out "Fast" setting on everything
  • Settings > Keyboard > Key Repeat > Fast
  • Settings > Keyboard > Delay Until Repeat > Short
  • Settings > Keyboard > Use all F1, F2, etc. keys as standard function key
  • Settings > Keyboard > Text > Disable "Correct spelling automatically"
  • Settings > Sound > Disable "Play user interface sound effects"
  • Settings > Sound > Alert volume > 0% (for Terminal ping)
  • Settings > Trackpad > Scroll & Zoom > Disable "Scroll direction: natural"
  • Settings > Energy Saver > Power Adapter > Display sleep > Never
  • Settings > Displays > Built-in Retina Display > Disable "Automatically adjust brightness"
  • Settings > Displays > Arrangement > drag and drop your external monitors into desired order
  • Settings > Dock > enable "Automatically hide and show the Dock"
  • Menu bar > Battery icon in task bar > Enable "Show Percentage"
  • iTerm > Preferences... > Profiles > Terminal > Unlimited Scrollback
Press Ctrl-Up arrow, add a few desktops (or "spaces" as they were used to know), then go to Settings > Keyboard > Shortcuts > Mission Control - and enable their keyboard shortcuts Ctrl-1 to Ctrl-6 or however many you have there.

Drivers

OSX already includes drivers for laptop itself, but you might need some for peripheral hardware.

If you need any keyboard drivers like for Microsoft Keyboard (otherwise Cmd key is in the wrong place) or just about any external keyboard, get necessary drivers.

If you need any special keyboard layouts, get them too.

Standard paths

OSX renames a lot of directories. While in theory scripts could just use env vars to find proper paths, it's more reliable to symlink all the things:

  sudo ln -s /Volumes /mnt
  sudo ln -s /Volumes /media
  sudo mv /home /home-old
  sudo ln -s /Users /home

Development tools

First, you'll need Xcode. Run xcode-select --install from command line to install it.

Now it's time for a package manager. They're all somewhat disappointing if you're used to apt-get. homebrew seems somewhat more popular than others these days, so you might just as well try that. You need to tell homebrew to not spy on you with brew analytics off command.

You'll also need X11 server like XQuartz.

Create new SSH key pair

Before you do that, name your computer something memorable with sudo scutil --set HostName your_host_name command.

Open Terminal and run ssh-keygen to create ~/.ssh/id_rsa, then upload the generated key to any place that needs to know about it like github, bitbucket, or whatever else you use.

Checkout your dotfiles

Hopefully you're storing your dotfiles somewhere. If it's a git repository, or your Dropbox account, get them now and symlink them all properly.

If there are any other repositories you might need, checkout them too.

Install homebrew packages

Your list might vary. Here's mine (fun story - order you install homebrew packages matters, every packaging system that's not apt-get sucks so hard):

brew install mongodb mysql postgresql rbenv ruby-build wget htop unrar mc mplayer coreutils libxml2 libxslt bash poppler redis qt youtube-dl trash rabbitmq pcre exiftool lame id3v2 sox jq git bash-completion p7zip imagemagick

Then enable all services you installed, unless you want to start them manually:

  ln -sfv /usr/local/opt/*/*.plist ~/Library/LaunchAgents/

And install non-system ruby, so you can install gems without sudo:

  rbenv install 2.4.0-dev
  rbenv global 2.4.0-dev

To make that actually work, you need to make sure ~/.rbenv/shims is in your $PATH.

Due to OSX limitations you'll need to run sudo htop if you want to use htop.

Sane bash and coreutils

bash version shipped with OSX is ancient and BSD utilities are all awful. In previous steps you installed proper versions, now you need to tell the system to use it.

Add homebrew version of bash as allowed shell by appending /usr/local/bin/bash at end of /etc/shells

Then set it as your shell: chsh -s /usr/local/bin/bash $USER

Then make sure to add GNU coreutils to your PATH:

  export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
  export MANPATH="/usr/local/opt/coreutils/libexec/gnuman:$MANPATH"

You'll also probably want to touch ~/.hushlogin to prevent some worthless spam on every open terminal tab.

Install gems

Again, your list my vary. Here's mine:

gem install beeminder moneta octokit term-ansicolor pry-plus rak objectiveflickr hpricot color nokogiri bundler

All other software

Sadly OSX window manager is extremely dubious for keyboard use. Fortunately programs to make it usable exist. I recommend installing these two:
  • ShiftIt - for tiling by keyboard shortcuts.
  • HyperSwitch - for sane alt-tab window switching. (there's also Witch, but it has issues with 10.10)
You'll need to give them necessary access. To do so:
  • Settings > Security & Privacy > Privacy > Allow the apps below to control your computer > enable them both
You'll probably need these or similar programs:
Once upon a time Open Source Mac website contained links to a lot of useful software, but these days targets seem to be malware infested crap a lot. Don't go there.

Enjoy

Once you go through this list, and successfully get everything going, I'd recommend modifying it to your liking and reposting your version on your blog. Everybody's needs are different, so guide like this is just a starting point.

No comments: