This is a guide for setting up an Apple Mac for software development. Current versions of macOS have a fairly good default configuration for general-purpose use, but you do need to to adjust some of the security settings. In addition, you need to install several pieces of software in order to make the system useful for development.
Log in once, run Software Update, and ensure that the operating system is at the latest point release. After all of the updates have been applied, restart the computer.
Log in again and create an Admin user account for your use. If other people will be using the machine, create Standard accounts for them. Log out of the initial account, and log in to the Admin account that you have just created.
You should also find an external hard drive. Begin using Time Machine as soon as possible, as it provides the most easy method for backing up your system.
To make the trackpad behave correctly, ensure that these settings are enabled:
- System Preferences > Trackpad > Tap to click
- System Preferences > Accessibility > Mouse & Trackpad > Trackpad Options… > Enable dragging
- System Preferences > Trackpad > Scroll Direction : Natural
Select System Preferences > Security & Privacy, and set the following:
- Under General, set require a password after sleep or screen saver begins to immediately
- Click Advanced… and select Require an administrator password to access system-wide preferences
- Under Firewall, click Turn Firewall On.
- Put System Preferences in the Dock.
- Enable keyboard access for all controls
-
When filling out forms, tapping the Tab key allows you to cycle through text boxes and lists only by default. While this is helpful, drop-down boxes, radio buttons, and other forms of input are skipped entirely.
-
To change this behavior and allow for tabbing through all forms of input, go to System Preferences > Keyboard > Shortcuts. Select the radio button for All Controls under the Full Keyboard Access to enable this function
-
If you're going to use Alfred then uncheck Spotlight. Go to System Preferences > Keyboard > Shortcuts and then in the Spotlight tab uncheck Show Spotlight Search
Below are some settings that may help your experience with Finder all the more useful:
- Modify the View/Layout of the Finder. Go to View > Change Layout.
- Enable Status Bar and Path Bar. View > Show Path Bar/ Status Bar.
- Adjust Finder settings to list folders above files. Go to Finder > Preferences > Advanced > Keep Folders On Top When Sorting By Name
- Go to General and check everything.
Action | Shortcut |
---|---|
Force Quit an App | ⌘ + Option + Esc |
Quick Look | Space |
View Hidden Files | ⌘ + Shift + . |
Forward Delete | Fn + Delete |
Delete word by word | Option + Delete |
Scroll to Very Top/Bottom | ⌘ + Up or Down |
Scroll to Start/End of line | ⌘ + Right/Left |
Take a screenshot of the entire screen | ⌘ + Shift + 3 |
Take a screenshot of an area of the screen | ⌘ + Shift + 4 |
Current versions of macOS include File Vault 2, a full-disk encryption system that has little in common with the much more limited File Vault 1. You should enable File Vault NOW, because it is the only protection against anyone with physical access to your computer. All other security measures will be completely bypassed if someone with physical access simply restarts the computer with a bootable pen drive.
File Vault really is secure, which means that you can permanently lose access to your data if you lose the passwords and the recovery key.
Time Machine is simple to set up. Just take a suitably large external hard drive, plug it in to your Mac, and agree when prompted. The drive setup process will reformat the hard drive. The only settings that may need to change are the exclusions.
Choose System Preferences > Time Machine, and click Options. Add to the exclusions list any folders that contain ISO disk images, virtual machines, or database files (such as Entourage). If the external hard drive is short of space, exclude the System folder.
If you want to download apps from the web at large and not just from the Mac App Store, you'll need to tell macOS to loosen up on the reins a bit. Go to System Preferences > Security & Privacy, click the General tab and then click lock in the lower-left corner and enter your password to make changes. Next, for Allow apps downloaded from choose App Store and identified developers.
Siri doesn't have to speak her responses aloud—she can silently display them on screen. If you'd prefer this option, open System Preferences > Siri. Finally, next to the Voice Feedback heading, tick Off. From the same dialog box, you can tweak other aspects of Siri: Try changing the voice, and if you prefer a less cluttered interface, experiment with hiding the icon from the menu bar.
The first step is to install a compiler. The easiest way to install one is with the Xcode Command Line Tools package.
Once you have the compiler that is provided by Xcode, you can use Homebrew to install everything else that you need. Homebrew itself manages packages for command-line tools and services. The Cask extension to Homebrew enables you to install graphical desktop applications.
Apple now provide the Xcode suite as a free download from the App Store. To install Xcode Command Line Tools, install Xcode from the App Store, then open a Terminal window and enter the following command:
xcode-select --install
You can skip installing XCode from the App Store and directly execute the above command. A dialog box will open saying install complete XCode or just the XCode Command Line Tools. Choose whichever option you want.
Run the macSetup.sh
in your $HOME folder for all the steps listed below to happen automatically after installing xcode. But make sure you input your own credentials in the script before running it.
Homebrew provides a package management system for macOS, enabling you to quickly install and update the tools and libraries that you need. Follow the instructions on the site.
You should also amend your PATH, so that the versions of tools that are installed with Homebrew take precedence over others. To do this, edit the file .bash_profile in your home directory to include this line:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH" >> $HOME/.bash_profile
Then update brew to the latest version and then installing cask
brew update
brew tap caskroom/cask
The Xcode Command Line Tools include a copy of Git, which is now the standard for Open Source development, but this will be out of date.
To install a newer version of Git than Apple provide, use Homebrew. Enter this command in a terminal window:
brew install git
Always set your details before you create or clone repositories on a new system. This requires two commands in a terminal window:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global color.ui auto
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset%n' --abbrev-commit --date=relative --branches"
git config --global alias.blg "log --graph --pretty=oneline --abbrev-commit"
The last two are git aliases to view the commit/branch log history for git initialised repositories. Execute git lg
to view the entire branch tree from master to all nodes in a tree fashion. Execute git blg
to view the branch history and its nodes for the current branch that you are in(branch that you have checked out to).
If you think the terms lg and blg are not to your liking just change the names near the alias.*
in the last 2 lines above for your chosen terms. Change it in the execute.sh
file if you use that.
The simplest way to generate a key pair is to run ssh-keygen without arguments. In this case, it will prompt for the file in which to store keys.
First, the tool asked where to save the file. SSH keys for user authentication are usually stored in the user's $HOME/.ssh
directory. Then it asks to enter a passphrase. The passphrase is used for encrypting the key, so that it cannot be used even if someone obtains the private key file. The algorithm is selected using the -t
option and key size using the -b
option. The following commands illustrate:
ssh-keygen -t rsa -b 4096
ssh-keygen -t dsa
ssh-keygen -t ecdsa -b 521
ssh-keygen -t ed25519
Your identification has been saved in $HOME/.ssh/id_rsa
. Your public key has been saved in $HOMe/.ssh/id_rsa.pub
. Copy the public key to copy to you GitHub account or wherever
Run git config --global credential.helper osxkeychain
to save your username and password so that you dont have to re-enter the credentials again whenever dealing with remotes.
To install Visual Studio Code, enter this command in a terminal window:
brew cask install visual-studio-code
Set the EDITOR environment variable to open VS Code as the default text editor[OPTIONAL].
export EDITOR="code -w" >> $HOME/.bash_profile
Cleanup the unneeded dependencies
brew cleanup
Unfortunately, macOS includes a copy of Python 2, so you will need to install Python 3 yourself. To maintain current and clean Python environments, you should also install pipenv. It drives the pip and virtual environment features that are included with Python itself, but is more powerful and easier to use than working with these features directly.
Enter this command to install Python 3 and pipenv using Homebrew:
brew install python3 pipenv
python3 -V
Installation of R and RStudio is easy with brew.
brew install r
brew cask install rstudio
Note: Run the rPackages.R
to install the basic libraries for R developement.
Visit here to download the .dmg file. Drag the installer icon to the Applications folder in the installer page.
You then need to set the $JAVA_HOME variable so that applications know where to look for the JDK. Use export $JAVA_HOME=/location/where/jdk/is/installed/ >> ~/.bash_profile
. Most probably the JDK is installed in /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk. But you can execute echo $(/usr/libexec/java_home)
to find the directory in which the JDK is installed.
NOTE: Every time you make a change to the .bash_profile you have to refresh bash so that it can make the changes so either close all terminal windows and reopen or execute source $HOME/.bash_profile
.
Use Homebrew to install node and npm(automatically downloaded on node installation).
brew install node
node -v
npm -v
To install create-react-app
use npm to install it. The -g tag installs it globally. You can remove that to install it locally.
npm install -g create-react-app
Since we're going to be spending a lot of time in the command-line, let's install a better terminal than the default one. Download and install iTerm2. Or using Homebrew, you can install iTerm2.
brew cask install iterm2
To see if any formulae of yours, are outdated:
brew outdated
Run the following to upgrade any one.
brew upgrade <formula>
It's totally a personal preference. I like my terminal to look a certain way. I also like having the git branch displayed in those directoried with git initialised. Add the lines below to the end of $HOME/.bash_profile
file.
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOR="\[\033[0m\]"
BLUE="\[\033[01;34m\]"
PS1="$YELLOW(\!)$GREEN \u:$BLUE\w$NO_COLOR\$(parse_git_branch)\n$RED\$ $NO_COLOR"
In the end it will look something like this
If you saved your workspace settings in a gist, then install the 'Settings Sync' extension from the Marketplace and then follow the instructions there to download and sync your settings.
The script automatically will install Chrome, Spotify, Slack, VLC, Visual Studio Code, Alfred, Spectacle, Cheatsheet, Slack and Tunnelbear automatically.
It also installs tree
extension for brew and wget
for accessing links from the internet.
It also changes the folowing macOS settings:
#"Allowing text selection in Quick Look"
defaults write com.apple.finder QLEnableTextSelection -bool TRUE
#"Check for software updates daily, not just once per week"
defaults write com.apple.SoftwareUpdate ScheduleFrequency -int 1
#"Showing icons for hard drives, servers, and removable media on the desktop"
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
#"Showing all filename extensions in Finder by default"
defaults write NSGlobalDomain AppleShowAllExtensions -bool true
#"Disabling the warning when changing a file extension"
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
#"Avoiding the creation of .DS_Store files on network volumes"
defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true
#"Enabling snap-to-grid for icons on the desktop and in other icon views"
/usr/libexec/PlistBuddy -c "Set :DesktopViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :FK_StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
/usr/libexec/PlistBuddy -c "Set :StandardViewSettings:IconViewSettings:arrangeBy grid" ~/Library/Preferences/com.apple.finder.plist
#"Setting screenshots location to ~/Pictures/Screenshots"
defaults write com.apple.screencapture location -string "$HOME/Pictures/Screenshots"
#"Setting screenshot format to PNG"
defaults write com.apple.screencapture type -string "png"
#"Use `~/Downloads/Incomplete` to store incomplete downloads"
defaults write org.m0k.transmission UseIncompleteDownloadFolder -bool true
defaults write org.m0k.transmission IncompleteDownloadFolder -string "$HOME/Downloads/Incomplete"
``