HeadshotAlexander Reelsen

Creating a productive osx environment

In order to be productive with a fresh OSX installation, a fair share of tweaks are necessary. Especially, when you are coming from the Linux world, where you are used to everything being configurable.

This post explains some of my setup - which may be completely different to yours, but it helps a lot to get up and running.

Install xcode, brew & cask

I think this is the absolutely first and necessary step. brew and cask allow you to escape the .dmg hell (manually installing all the things) installing a lot of tools manually. With the exception of my 8 year old multi function printer I did not have to install any software package manually. Yes, when starting with nodemcu development again, I will have to, but still this should be kept to an absolute minimum.

First you should install xcode. You can install it from the command line, but as far as I know, there is no drawback to install it from the app store either.

After this it is easy to install brew first and cask second. which can be done via brew install brew-cask. You can search for applications using brew search or brew cask search.

Install applications

A couple of applications that I usually have installed and help my personal productivity (this is just extracted from brew list and brew cask list)

Brew

Cask

Changing defaults

You can change some nasty defaults using the defaults command line tool.

# Disable `gamed` process
defaults write com.apple.gamed Disabled -bool true

# Disable the sound effects on boot
sudo nvram SystemAudioVolume=" "

# Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true

# Check for software updates daily, not just once per week
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1

# Disable smart quotes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false

# Disable smart dashes as they’re annoying when typing code
defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false

# Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0

Command line

To me, the command line is still the most productive tool on OSX, so I try to set it up, until it suites my needs.

Shell

I do not differentiate a lot between bash and zsh, but on my local system I prefer nicely themed terminals with as much completion as I can get. And that is just simple to set up with zsh and all the nice helper tools built around it. The one I use is prezto, in combination with the powerline theme. I played around a bit with the prompts and ended up with this config in modules/prompt/external/powerline/prompt_powerline_setup

POWERLINE_LEFT_A="%K{75}%F{black} %~ %k%f%F{75}%K{60}"$POWERLINE_SEPARATOR
POWERLINE_LEFT_B="%k%f%F{white}%K{60} "'${vcs_info_msg_0_}'" %k%f%F{60}%K{black}"$POWERLINE_SEPARATOR
POWERLINE_LEFT_C="%k%f%F{white}%K{black}%k%f%F{black}"$POWERLINE_SEPARATOR"%f"
#RPROMPT="..."

I removed the right prompt completely and changed the colors of the left, so I end up, looking like this:

My terminal

Aliases & functions

I do not have an awesome lot of helping aliases and/or functions, just a few to help

The first one is lockscreen to be able to lock the screen via a terminal command

alias lockscreen="open -a /System/Library/Frameworks/ScreensSaver.framework/Versions/A/Resources/ScreenSaverEngine.app"
alias pdfjoin="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py"

The next one is the potential of printing pretty. Python has some nice pretty printer built-in, which can be invoked by running python -mjson.tool. However, there is a much more powerful tool called underscore-cli. underscore-cli not only does pretty printing and coloring, you can also filter and select parts of that JSON. In order to install it, install node and then run npm -g install underscore-cli. Pretty-printing JSON then looks like this

underscore-cli in action

also, you should alias underscore pretty to a shortcut like pp, like done above

In case you are hanging out at hotels/airports/public places with limited availability based on the MAC address, this little gist gives you a function to configure your interface to have a random MAC. Just call remac from the command line.

The function looks like this:

function remac() {
  local progress='.oO°Oo'
  local airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport
  local ssid=$($airport -I|awk '/^ *SSID/ {print $2}')
  local iface=$(networksetup -listallhardwareports|grep -A1 Wi-Fi|awk '/Device:/ {print $2}')
  local mac=${1:-00$(openssl rand -hex 5|sed 's/\(..\)/:\1/g')}
 
  echo Disconnecting Wi-Fi $iface from SSID $ssid to set new mac address $mac...
  sudo $airport -z
  local i n=0
  until ifconfig $iface ether | grep -q $mac ; do
    sudo ifconfig $iface ether $mac
    sleep .1
    i=$[++n % $#progress + 1]
    echo -n "$progress[$i]\r"
  done
 
  networksetup -setairportnetwork $iface $ssid \
  && echo mac is $mac \
  || echo failed $mac && false
}

Depending on your use-case you may need to configure different JDKs, you can usually use the /usr/libexec/java_home for this and use a parameter like -v 1.7 or -v 1.8 if you have several JDKs installed.

vim

Stock vim is already awesome, but there are some things, that can make it even more awesome. First off, you can install a ton of plugins on top of vim, ranging from adding functionality, syntax highlighting, search functionality and many more. The plugin manager is I use is vundle, which is available at github

My configuration looks like this

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" jade syntax support
Plugin 'digitaltoad/vim-jade'
" nice JS syntax color
Plugin 'goatslacker/mango.vim'
" zencoding style
Plugin 'mattn/emmet-vim'
" jshint
Plugin 'walm/jshint.vim'
" ctrl-p fast finder
Plugin 'kien/ctrlp.vim'
Plugin 'godlygeek/tabular'
" markdown support
Plugin 'plasticboy/vim-markdown'
" status line
Plugin 'itchyny/lightline.vim'

call vundle#end()

" lightline config
let g:lightline = {
      \ 'colorscheme': 'wombat' ,
      \ }

A quick overview about the different plugins

The theme makes vim look like this

vim using lightline and wombat theme

git

Nothing special about my git configuration, the two aliases below allow you to easily download a pull request and check it out locally and the fclone alias just clones the first level and thus saves a lot of bandwidth, if you just want to look something up or build the current build and do not need the full history.

[alias]
    pr = "!f() { git fetch origin pull/$1/head:pr/$1; }; f"
    fclone = "!f() { git clone --depth 1 $1; }; f"

Backup

If you were lazy, time machine is a nice and easy to use backup solution. Many home NAS solutions like QNAP already offer a time machine mode. Me being the command line guy and not sure about the TimeMachine format checked out existing backup solutions that backup into a file format that is readable from all operating systems and settled with tar.gz. The software I use is duply, which is based on duplicity. Duply is pretty simple to setup and run. If you seek alternatives, a couple of them are listed on the duply website. Always keen, what others are using, though.

Keyboard shortcuts everywhere

On to one of my favourite topics: keyboard shortcuts: This is the secret sauce of productivity, not having to move your hands to the mouse or the trackpad. I try to not use the mouse as much as possible, but it is still a habit. Whenever I found a new useful keyboard shortcut, I will put it up as a post-it note on my TFT to remind me to use it. This is how I learned most of the intellij shortcuts after switching from eclipse. I wont talk so much about about applications here, but rather about OSX. One of the tricky things is to ensure, that osx shortcuts do not interfere with application shortcuts (which unfortunately happens with intellij)

First off, I like spaces. I usually group my spaces by some topic (like my communication space has email, hipchat and IRC together), I highly dislike one space with all the applications. Switching from one space to another is just hitting ctrl+left/right arrow.

Most of the time I only have on iterm2 window open, which contains a fair share of terminals. Switching terminals works by using cmd+left/right arrow or cmd+number.

One of the most important shortcuts in osx for me is actually unbound. If you start several windows from one application (like several chrome windows each containing several tabs, usually needed for testing web apps in private mode), there is no possibility to just page through those by default. However you can configure this in the System Preferences -> Keyboard -> Shortcuts. The correct shortcut is Move focus to next window and I usually bind that to alt+tab.

With the last major osx release to yosemite the behaviour of the green resizing button changed to move an app to full screen. Something I actually never want. Some applications support a double-click on their top bar to jump to maximum size, chrome for example only jumps to maximum height. In order to fix this erratic behaviour by just using the right keyboard shortcut, you should install ShiftIt using cask. By pressing ctrl+alt+cmd+m you can maximise any windows. There are a couple of other shortcuts, but this is the one I actually need most, when not using an external display.

Regarding intellij I usually keep the default shortcuts. My only change is to switch to the next/previous editor window, which is usually cmd+left/right, that is caught by osx. My workaround is to configure Main Menu -> Window -> Editor Tabs -> Select Next Tab/Select Previous Tab each to ctrl+shift+left/right.

Fonts

A fresh installed osx does lack a couple of fonts. You should install Calibri (used by Microsoft, so might be needed for some presentations) and find yourself a couple of awesome fonts at Google Fonts, that you use for presentations. Speaking of awesome fonts, make sure you also install stuff like Font Awesome (used by Bootstrap or Semantic-UI), so you can use neat icons in presentations.

Going dark

One of the things I usually do immediately is try to switch to dark themes by default

Ping me for other nice dark apps, happy to include them

Chrome

Just a few minor notes about chrome, which comes with nice configuration out of the box. I would always disable the password manager. I switched my default search engine to duckduckgo, just add a google like query https://duckduckgo.com/?q=%s to your search engine config. Might be a nice plugin to actually randomize each search to another search engine…

If you do not want to put your chrome settings into the internet, you can use this useful little python script called py-chrome-bookmarks to import/export your bookmarks.

Chrome Plugins

Elasticsearch

As I do work for elastic, I will just include a couple of nice tools, that I use for my daily work here as well, that might be useful, in case you use Elasticsearch, logstash or kibana.

Notifications

One last word about notifications. I think they are bad, but that is obviously just me. I really dislike notifications like chat notifications that have not been directed to me and try to disable those whenever possible. Same for email or commits of the projects I am working on. This also implies that tools like the terminal-notifier should be used scarcely.

If you need to do focus work, maybe a shell script tuning down those notifications already helps a lot.

Next steps

That’s it. I just scratched the surface of what to do, after you got a fresh installation of OSX, and I am sure there are millions of things all of us developers do different as we all have different habits. This at least helps me to remind certain things.

If you have any tools to recommend, drop me a note and I will create another blog post. I try to refrain to include any commercial tools in here for now. I think there is enough awesome open source software available in the world. If not, we need to fix it.

Also, there are a fair share of links about commandline productivity out there, feel free to check the art of command line, bash one liners or github dotfiles to do the next steps.