This blog post contains a collection of small tips for engineers migrating from GNU/Linux to Mac OS X for software development.
Note: In another post, I wrote about why there is a dearth of a good GNU/Linux laptop. Mac is based on Open BSD which is similar to GNU/Linux but there are quite a few major differences from GNU/Linux. My exposure to BSD is limited, so, I won’t even try to draw a comparison here. Following are some things that I learned and have been useful.
Software Packages
The default style of software installation is slightly weird on Mac. Most software comes in the form of a .dmg file (like .msi for Windows). One has to open the dmg and then drag it to the Applications directory. To uninstall, one can just delete the directory. OS X saves software packages in /Applications directory.
Here are some of my favorites,
- Finder (installed by default) – Mac version of Gnome Nautilus or Windows Explorer. Tip: Cmd + O – open the file while pressing “enter” edit the filename.
- iTerm2 – Terminal app
- XQuartz – for running software that requires an X11 windowing system. For example, Wireshark requires it.
- Quicksilver – Universal search for Mac. After installing this app, use Cmd + space to trigger it and type anything from filename to application name
- Zipeg – Archive viewer
- Xcode – Development Tools. IMHO, it is impossible to survive without this. A lot of other packages mentioned further depend on Xcode.
- VMWare Fusion – for running GNU/Linux virtual machines. It is not free. There are free alternatives like VirtualBox. Some combine this with Vagrant.
- MacVim – For those who just want to use Vim without the terminal. I prefer Vim instead.
- MplayerX – for watching offline videos
Unlike apt-get on Ubuntu or yum on Fedora, Mac does not come with a command-line package manager. The solution is to use homebrew. I have tried MacPorts as well and I feel homebrew is more polished.
To install homebrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Now to install wget, which does not come by default on Mac machines, do
brew install wget
To look around for brew formulas related to GNU coreutils, do
brew search coreutils
By default, brew can only install command-line GNU/Linux-style tools.
To install a Mac app (.dmg packages), one can enable cask via,
brew install caskroom/cask/brew-cask
Now, Google Chrome can be installed via,
$ brew cask install google-chrome
I started using brew cask only recently and my setup can be found here. For Python-based packages, one can use easy_install pip. For ruby-based packages use gem install. The default version of Ruby is old, upgrade using brew. Try rvm if your main job is to do ruby-based software development. For node.jsbased packages install npm (brew install npm). I have not done any rigorous C/C++ development on Mac, so, I am not sure about how good it is.
CLI
- Bash shipped with Mac is old, better to upgrade to the latest.
$ brew install bash
- pbcopy, pbpaste – interacts with pasteboard, which is Mac’s clipboard.
$ echo "copy this to clipboard" | pbcopy $ pbpaste # Pastes the content of clipboard
- open is the standard command for opening any file (it chooses the relevant application).
- defaults is for modifying settings of various apps via the command line, e.g.
$ defaults read
to see a list of all such settings.
- Default autocomplete settings for commands in Mac are subpar. My collection of fixes is here.
- A lot of other default settings in Mac are not developer-friendly. My .osx file is here, it is based on the legendary .osx files from Mathias. Feel free to read my dotfiles and also for more examples http://dotfiles.github.io/.
Minor Things
- Filenames are case-insensitive, by default, on the Mac OS Extended (Journaled) file system.
- Right mouse click – Cmd + click
- Closing a window does not close the application, Cmd + Q does.
- Default key repeat speed is slow for programming. Following is a fix for that (taken from the source)
$ defaults write NSGlobalDomain KeyRepeat -int 0
- Try out two-finger, three-finger, and four-finger swipes on the trackpad. It is pretty amazing.
- All credentials (like wifi passwords, certificates, etc.) are stored in the Keychain app.
$ open -a "Keychain Access"
- To list all the applications installed on the system use (taken from source)
$ system_profiler SPApplicationsDataType -xml
(system_profiler in general, is a pretty useful command as well).