This is my updated fork of nicolashery's mac-dev-setup. I've added some from:
- hacker codex.
- Mac OS X Setup Guide
- Saetia/g3d mac setup gist
- Hacker's Guide to Setting up Your Mac
- osx-for-hackers script
These pages may be of use:
- OS X Web Development
- Developing on OS X Yosemite
- Definitive guide to setting up a new mac for development
- How I Set Up My Mac Development Machine
- Get Mac Apps <- alternative to Homebrew Cask
Applications to cover:
- Karabiner
- Better Touch Tool
- Keyboard Maestro
- TextExpander
Note: Everything starting with Beautiful Terminal is unchanged from my fork. This is still a WIP
Paid tools I like:
- Navicat (SQL GUI - I use Premium Essentials, covers many databases)
- Transmit (Excellent FTP/SFTP client)
- Textual (IRC Client)
- Colloquy is also great and free, but seems to have less active development these days
Well reviewed tools I want to look into:
-
CodeKit (Front End Toolbox)
-
Kaleidoscope (Incredible diff tool for more than text)
-
Shapes - possible alternative to OmniGraffle
-
Exedore - Mac Specific Python IDE
-
Tower (Git Manager)
-
Dash - offline documentation browser and code snippet manager
-
Quiver - programmers notebook
-
Graphics
This document describes how I set up my developer environment on a new MacBook or iMac. We will set up Node (JavaScript), Python, and Ruby environments, mainly for JavaScript and Python development. Even if you don't program in all three, it is good to have them as many command-line tools use one of them. This is mostly for personal reference, but may be useful for others.
The document assumes you are new to Mac. The steps below were tested on OS X 10.11 El Capitan.
- System update
- System preferences
- Safari
- Text Editors and IDEs
- Compiler
- Homebrew
- Homebrew Cask
- iTerm2
- Fonts
- Beautiful terminal
- Git
- Sublime Text
- Vim
- Python
- Virtualenv
- IPython
- Numpy and Scipy
- MySQL
- Node.js
- JSHint
- Ruby and RVM
- LESS
- Heroku
- MongoDB
- Redis
- Elasticsearch
- Projects folder
- Apps
First thing you need to do, on any OS actually, is update the system! For that: Apple Icon > App Store and click on Updates at the top
If this is a new computer, there are a couple tweaks I like to make to the System Preferences. Feel free to follow these, or to ignore them, depending on your personal preferences.
In Apple Icon > System Preferences:
- Trackpad > Tap to click
- Keyboard > Key Repeat > Fast (all the way to the right)
- Keyboard > Delay Until Repeat > Short (all the way to the right)
- Spotlight > Uncheck fonts, images, Bing etc.
- Spotlight > Keyboard shortcuts > uncheck so Cmd-Space can be used by Alfred
- Size - about 10%
- Magnification - set to about 60%
- Position on screen: Left
- General > Require password 1 minute after sleep
- General > Allow apps downloaded from: Mac App Store and identified developers
- Toolbar
- Update to add Path
- Menu -> Go -> Connect to Server
- add share for work "smb://192.168.0.1/dir" and hit +
- Sidebar
- Add home and code direcotry
- Preferences
- General > New folder windows show: home directory
- Sidebar > Show computer under Devices
Just like the last few releases, Mac OS X now hides the ~/Library folder by default, but on Yosemite and Mavericks it is now easier to make it visible again.
With the Finder as the foremost application, press shift-command-H and then command-J, which will bring up a window that configures Finder view options. Check the “Show Library Folder” and close the window. Thanks to the Apple engineers that made this process more user-friendly.
Note: Some of these are duplicates of above
#Fix fonth smoothing
defaults -currentHost write -globalDomain AppleFontSmoothing -int 0
#Disable window animations
defaults write NSGlobalDomain NSAutomaticWindowAnimationsEnabled -bool false
#Enable repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false
#Disable webkit homepage
defaults write org.webkit.nightly.WebKit StartPageDisabled -bool true
#Use current directory as default search scope in Finder
defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"
#Show Path bar in Finder
defaults write com.apple.finder ShowPathbar -bool true
#Show Status bar in Finder
defaults write com.apple.finder ShowStatusBar -bool true
#Show indicator lights for open applications in the Dock
defaults write com.apple.dock show-process-indicators -bool true
#Enable AirDrop over Ethernet and on unsupported Macs running Lion
defaults write com.apple.NetworkBrowser BrowseAllInterfaces -bool true
#Set a blazingly fast keyboard repeat rate
defaults write NSGlobalDomain KeyRepeat -int 0.02
#Set a shorter Delay until key repeat
defaults write NSGlobalDomain InitialKeyRepeat -int 12
#Disable disk image verification
defaults write com.apple.frameworks.diskimages skip-verify -bool true &&
defaults write com.apple.frameworks.diskimages skip-verify-locked -bool true &&
defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
#Disable Safari’s thumbnail cache for History and Top Sites
defaults write com.apple.Safari DebugSnapshotsUpdatePolicy -int 2
#Enable Safari’s debug menu
defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
#Disable the Ping sidebar in iTunes
defaults write com.apple.iTunes disablePingSidebar -bool true
#Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
#Show the ~/Library folder
chflags nohidden ~/Library
#Disable ping dropdowns
defaults write com.apple.iTunes hide-ping-dropdown true
#Expand the save panel by default
defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint -bool true
defaults write NSGlobalDomain PMPrintingExpandedStateForPrint2 -bool true
#Automatically quit printer app once the print jobs complete
defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
#Disable the menubar transparency?
defaults write com.apple.universalaccess reduceTransparency -bool true
#Speed up wake from sleep to 24 hours from an hour
# http://www.cultofmac.com/221392/quick-hack-speeds-up-retina-macbooks-wake-from-sleep-os-x-tips/
sudo pmset -a standbydelay 86400
#Increasing sound quality for Bluetooth headphones/headsets
defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40
#Enable full keyboard access for all controls (enable Tab in modal dialogs, menu windows, etc.)
defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
#Disable press-and-hold for special keys in favor of key repeat
defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
#Disable auto-correct
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false
#Set trackpad & mouse speed to a reasonable number
defaults write -g com.apple.trackpad.scaling 2
defaults write -g com.apple.mouse.scaling 2.5
#Turn off keyboard illumination when computer is not used for 5 minutes
defaults write com.apple.BezelServices kDimTime -int 300
#Enabling subpixel font rendering on non-Apple LCDs
defaults write NSGlobalDomain AppleFontSmoothing -int 2
#Enable HiDPI display modes (requires restart)
sudo defaults write /Library/Preferences/com.apple.windowserver DisplayResolutionEnabled -bool true
#Set icon size of Dock items to 36 pixels
defaults write com.apple.dock tilesize -int 36
#Speeding up Mission Control animations and grouping windows by application
defaults write com.apple.dock expose-animation-duration -float 0.1
defaults write com.apple.dock "expose-group-by-app" -bool true
#Enable the Develop menu and the Web Inspector in Safari
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
defaults write com.apple.Safari "com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled" -bool true
#Add a context menu item for showing the Web Inspector in web views
defaults write NSGlobalDomain WebKitDeveloperExtras -bool true
#Use the system-native print preview dialog in Chrome
defaults write com.google.Chrome DisablePrintPreview -bool true
defaults write com.google.Chrome.canary DisablePrintPreview -bool true
#Enable UTF-8 ONLY in Terminal.app and set the Pro theme by default
defaults write com.apple.terminal StringEncodings -array 4
defaults write com.apple.Terminal "Default Window Settings" -string "Pro"
defaults write com.apple.Terminal "Startup Window Settings" -string "Pro"
Prevent Time Machine from prompting to use new hard drives as backup volume
defaults write com.apple.TimeMachine DoNotOfferNewDisksForBackup -bool true
#Disable local Time Machine backups? (This can take up a ton of SSD space on <128GB SSDs)
hash tmutil &> /dev/null && sudo tmutil disablelocal
$ sudo scutil --set HostName Work
- Show favorites bar
- Show status bar
- General
- Smart Search Field: Show full website address
- Show Develop menu in menu bar
- AutoFill
- Using info from my Contacts card
- User names and passwords
- Credit cards
- Other forms
- Passwords
- AutoFill user names and passwords
- Privacy
- Cookies and website data - allow from websites I visit
- Ask websites not to track me
- Extensions
- 1Password
- Instapaper
- Recent Tab List - probably don't need
- Ka-Block! - tracking blocker
- derpyme - link shortener
Text editors are where a developer spends a lot of their time. Therefore the text editor one uses is a very personal choice. I'm still a vim user when editing config files. But for the last couple of years I've been doing Python development with emacs and when adding web stuff, using either emacs or Sublime Text.
IDEs are amazing. I've used Visual Studio for C# and Eclipse and IntelliJ Idea for Java. They are tightly integrated with the languages, which allows them to do amazing things with re-factoring that even the newest text editors don't do very well. I couldn't imagine writing Java without an IDE, and I think an IDE is worthwhile for many large projects. All that said, I personally like the level of customization and speed I get from text editors when the language/project size allows it.
If you want to use a text editor, the big names right now are the venerable vim and emacs, along with the much more modern Sublime Text and Atom. There are also a few Mac exclusives that might be worth taking a look at.
- BBEdit - the editor that every Mac user had in the 90's and early 2000's
- TextWrangler - free editor from the makers of BBEdit
- Smultron - quick and easy to use, and inexpensive
- TextMate - I would argue that TextMate is a major reason that Apple was able to greatly increase market share in the 2000's. Web developers flocked to the platform for TextMate. Other developers and eventually mainstream users followed. TextMate was clearly the influence for the now super-popular Sublime Text, which itself was a major influence on Atom.
OK, let's talk about this for a minute. You don't need emacs, or even vim. Sublime Text is fine. The community is great, and there are tons of plugins and themes and tutorials available.
Emacs is different. Emacs is a living, breathing, monolithic environment, not a text editor. For hopping in and changing 3 specific spots in a config file, I can do it quicker in vim. To throw together a rough web site I can do it quicker with Sublime Text or Atom. But Emacs can be molded into what you want. You run your terminal, git, email client, chat client, outliner, and music player in it. They all have the same look and feel and key shortcuts. You build up a custom config for the way you want things to work, and because your config file is a series of function calls (and definitions!) you can build it in a way that it will automatically go out and grab everything you need on a new computer. Additionally, the keyboard shortcuts to move around text seem strange, but if you learn them, the same shortcuts will work in any native text field on OS X, and on any standard POSIX readline.
If you have used emacs in the past, you may be in for a surprise. The kind of problems that caused XEmacs to fork off have been largely solved. The GUI is using modern tooling across Windows/Mac/Linux, and there are modern theming and package systems. Org-mode is incredible, and serves as not only an outlining tool, but a task manager. It has become a world of it's own that now serves as the contact list and address book and blogging tool for many.
If you are interested in trying out emacs, check out tuhdo to at least get started. Then pick up Mickey Petersen's Mastering Emacs, money well spent.
Installing development-related software in the past has required the compiler tool-chain that comes with Xcode. Thankfully, if you don’t need or want Xcode, those compiler tools are now available separately, saving download time and about four gigabytes of disk space.
Alternatively, there are some reasons you might want the full version of Xcode:
-To compile the few tools that won’t compile without the full version of Xcode -To download and manually compile open-source Mac applications -To develop your own Mac/iOS applications
-Once you’ve decided whether you need Xcode or not, run the following command in the Terminal:
$ xcode-select --install
You will then be asked whether you want to install Xcode or the command line developer tools, with the latter being the default. Once you’ve installed one or the other, you can proceed to installing Homebrew.
Package managers make it so much easier to install and update applications (for Operating Systems) or libraries (for programming languages). The most popular one for OS X is Homebrew.
Finally, we can install Hombrew! In the terminal paste the following line (without the $), hit Enter, and follow the steps on the screen:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
One thing we need to do is tell the system to use programs installed by Hombrew (in /usr/local/bin) rather than the OS default if it exists. We do this by adding /usr/local/bin to your $PATH environment variable:
$ echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
Open a new terminal tab with Cmd+T (you should also close the old one), then run the following command to make sure everything works:
$ brew doctor
# To install a package (or **Formula** in Homebrew vocabulary) simply type:
$ brew install <formula>
# To update Homebrew's directory of formulae, run:
$ brew update
# To see if any of your packages need to be updated:
$ brew outdated
# To update a package:
$ brew upgrade <formula>
# Homebrew keeps older versions of packages installed, in case you want
# to roll back. That rarely is necessary, so you can use the cleanup
# command to get rid of those old versions:
$ brew cleanup
# To see what you have installed (with their version numbers):
$ brew list --versions
# You can use the info command to find out more about a given package
$ brew info ssh-copy-id
Note: Brew update will fail sometimes because of a bug. If that ever happens, run the following:
$ cd /usr/local
$ git fetch origin
$ git reset --hard origin/master
Let's grab some basics before going any further
binaries=(
graphicsmagick
webkit2png
rename
zopfli
ffmpeg
python
sshfs
trash
node
vim
ssh-copy-id
wget
zsh
tree
ack
hub
git
)
echo "installing binaries..."
brew install ${binaries[@]}
# Install GNU core utilities (those that come with OS X are outdated)
brew install coreutils
# Install GNU `find`, `locate`, `updatedb`, and `xargs`, g-prefixed
brew install findutils
# Install Bash 4
brew install bash
# Install more recent versions of some OS X tools
brew tap homebrew/dupes
brew install homebrew/dupes/grep
Get the elegance, simplicity, and speed of Homebrew for the installation and management of GUI Mac applications such as Google Chrome and Adium.
Install Homebrew-cask is really straight forward. We just need to add the cask tap and then install brew cask.
$ brew install caskroom/cask/brew-cask
$ brew cask install google-chrome
It is really simple to check if the app is supported by cask by going to the search page on caskroom.io
Some plugins to enable different files to work with Mac Quicklook. Includes features like syntax highlighting, markdown rendering, preview of jsons, patch files, csv, zip files etc.
$ brew cask install qlcolorcode
$ brew cask install qlstephen
$ brew cask install qlmarkdown
$ brew cask install quicklook-json
$ brew cask install qlprettypatch
$ brew cask install quicklook-csv
$ brew cask install betterzipql
$ brew cask install webpquicklook
$ brew cask install suspicious-package
An example script to install apps via brew cask
# Apps
apps=(
alfred
caffeine
dropbox
flux
google-chrome
iterm2
qlcolorcode
qlmarkdown
qlprettypatch
qlstephen
quicklook-json
spotify
sublime-text3
transmission
vlc
)
# Install apps to /Applications
# Default is: /Users/$user/Applications
echo "installing apps..."
brew cask install --appdir="/Applications" ${apps[@]}
Some other popular apps availabe via brew-cask:
airmail
android-file-transfer
appcleaner
arq
asepsis
atom
cheatsheet
cloudup
firefox
flash
google-drive
google-hangouts
hazel
latexian
mailbox
nvalt
onepassword
pdftk
spectacle
sublime-text
superduper
totalfinder
valentina-studio
screenflick
seil
shiori
sketch
skype
slack
tower
transmit
vagrant
virtualbox
One thing you may notice if you're an Alfred user is that you cannot actually launch these apps from Alfred because the actual location of the app is not in /Applications but in /opt/homebrew-cask/Caskroom/.
To add this path to Alfred, you can run the following command:
$ brew cask alfred link
Voila!
We installed it via cask above.
Let's just quickly change some preferences. In iTerm > Preferences..., under the tab General, uncheck Confirm closing multiple sessions and Confirm "Quit iTerm2 (Cmd+Q)" command under the section Closing.
In the tab Profiles, create a new one with the "+" icon, and rename it to your first name for example. Then, select Other Actions... > Set as Default. Finally, under the section Window, change the size to something better, like Columns: 125 and Rows: 35.
When done, hit the red "X" in the upper left (saving is automatic in OS X preference panes). Close the window and open a new one to see the size change.
# (optional) install latest zsh with homebrew (currently 5.0.6)
$ brew install zsh
# get oh-my-zsh
$ curl -L http://install.ohmyz.sh | sh
A few tweaks for your .zshrc ZSH=$HOME/.oh-my-zsh ZSH_THEME="candy" plugins=(git osx rails3 ruby github node npm brew) source $ZSH/oh-my-zsh.sh export PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/usr/X11/bin
Cask can also be used to automatically download and install fonts. In order to enable this, you'll need to tap the fonts cask:
$ brew tap caskroom/fonts
The font recipes are prefixed by font-*, so if you want to download Roboto, try searching for font-roboto:
$ brew cask search /font-roboto/
Here's a script to install fonts:
# fonts
fonts=(
font-m-plus
font-clear-sans
font-roboto
)
# install fonts
echo "installing fonts..."
brew cask install ${fonts[@]}
You can find a full list of the fonts in the caskroom/homebrew-fonts repo.
Another popular coding font is Consolas. Being a Microsoft (!) font, it is not installed by default.
There are two ways we can install it. If you bought Microsoft Office for Mac, install that and Consolas will be installed as well.
If you don't have Office, follow these steps:
$ brew install cabextract
$ cd ~/Downloads
$ mkdir consolas
$ cd consolas
$ curl -O http://download.microsoft.com/download/f/5/a/f5a3df76-d856-4a61-a6bd-722f52a5be26/PowerPointViewer.exe
$ cabextract PowerPointViewer.exe
$ cabextract ppviewer.cab
$ open CONSOLA*.TTF
And click Install Font. Thanks to Alexander Zhuravlev for his post.
Since we spend so much time in the terminal, we should try to make it a more pleasant and colorful place. What follows might seem like a lot of work, but trust me, it'll make the development experience so much better.
Let's go ahead and start by changing the font. In iTerm > Preferences..., under the tab Profiles, section Text, change both fonts to Consolas 13pt.
Now let's add some color. I'm a big fan of the Solarized color scheme. It is supposed to be scientifically optimal for the eyes. I just find it pretty.
Scroll down the page and download the latest version. Unzip the archive. In it you will find the iterm2-colors-solarized folder with a README.md file, but I will just walk you through it here:
- In iTerm2 Preferences, under Profiles and Colors, go to Load Presets... > Import..., find and open the two .itermcolors files we downloaded.
- Go back to Load Presets... and select Solarized Dark to activate it. Voila!
Note: You don't have to do this, but there is one color in the Solarized Dark preset I don't agree with, which is Bright Black. You'll notice it's too close to Black. So I change it to be the same as Bright Yellow, i.e. R 83 G 104 B 112.
Not a lot of colors yet. We need to tweak a little bit our Unix user's profile for that. This is done (on OS X and Linux), in the ~/.bash_profile text file (~ stands for the user's home directory).
We'll come back to the details of that later, but for now, just download the files .bash_profile, .bash_prompt, .aliases attached to this document into your home directory (.bash_profile is the one that gets loaded, I've set it up to call the others):
$ cd ~
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.bash_profile
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.bash_prompt
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.aliases
With that, open a new terminal tab (Cmd+T) and see the change! Try the list commands: ls, ls -lh (aliased to ll), ls -lha (aliased to la).
At this point you can also change your computer's name, which shows up in this terminal prompt. If you want to do so, go to System Preferences > Sharing. For example, I changed mine from "Nicolas's MacBook Air" to just "MacBook Air", so it shows up as MacBook-Air in the terminal.
Now we have a terminal we can work with!
(Thanks to Mathias Bynens for his awesome dotfiles.)
You may be interested in iTerm2 Color Schemes
What's a developer without Git? To install, simply run:
$ brew install git
When done, to test that it installed fine you can run:
$ git --version
And $ which git should output /usr/local/bin/git.
Let's set up some basic configuration. Download the .gitconfig file to your home directory:
$ cd ~
$ curl -O https://raw.githubusercontent.com/nicolashery/mac-dev-setup/master/.gitconfig
It will add some color to the status, branch, and diff Git commands, as well as a couple aliases. Feel free to take a look at the contents of the file, and add to it to your liking.
Next, we'll define your Git user (should be the same name and email you use for GitHub and Heroku):
$ git config --global user.name "Your Name Here"
$ git config --global user.email "your_email@youremail.com"
They will get added to your .gitconfig file.
To push code to your GitHub repositories, we're going to use the recommended HTTPS method (versus SSH). So you don't have to type your username and password everytime, let's enable Git password caching as described here:
$ git config --global credential.helper osxkeychain
Note: On a Mac, it is important to remember to add .DS_Store (a hidden OS X system file that's put in folders) to your .gitignore files. You can take a look at this repository's .gitignore file for inspiration.
With the terminal, the text editor is a developer's most important tool. Everyone has their preferences, but unless you're a hardcore Vim user, a lot of people are going to tell you that Sublime Text is currently the best one out there.
Go ahead and download it. Open the .dmg file, drag-and-drop in the Applications folder, you know the drill now. Launch the application.
Note: At this point I'm going to create a shortcut on the OS X Dock for both for Sublime Text and iTerm. To do so, right-click on the running application and select Options > Keep in Dock.
Sublime Text is not free, but I think it has an unlimited "evaluation period". Anyhow, we're going to be using it so much that even the seemingly expensive $70 price tag is worth every penny. If you can afford it, I suggest you support this awesome tool. :)
Just like the terminal, let's configure our editor a little. Go to Sublime Text 2 > Preferences > Settings - User and paste the following in the file that just opened:
{
"font_face": "Consolas",
"font_size": 13,
"rulers":
[
79
],
"highlight_line": true,
"bold_folder_labels": true,
"highlight_modified_tabs": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"word_wrap": false,
"indent_to_bracket": true
}Feel free to tweak these to your preference. When done, save the file and close it.
I use tab size 2 for everything except Python and Markdown files, where I use tab size 4. If you have a Python and Markdown file handy (or create dummy ones with $ touch dummy.py), for each one, open it and go to Sublime Text 2 > Preferences > Settings - More > Syntax Specific - User to paste in:
{
"tab_size": 4
}Now for the color. I'm going to change two things: the Theme (which is how the tabs, the file explorer on the left, etc. look) and the Color Scheme (the colors of the code). Again, feel free to pick different ones, or stick with the default.
A popular Theme is the Soda Theme. To install it, run:
$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
$ git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"
Then go to Sublime Text 2 > Preferences > Settings - User and add the following two lines:
"theme": "Soda Dark.sublime-theme",
"soda_classic_tabs": true
Restart Sublime Text for all changes to take effect (Note: on the Mac, closing all windows doesn't close the application, you need to hit Cmd+Q).
The Soda Theme page also offers some extra color schemes you can download and try. But to be consistent with my terminal, I like to use the Solarized Color Scheme, which already ships with Sublime Text. To use it, just go to Sublime Text 2 > Preferences > Color Scheme > Solarized (Dark). Again, this is really according to personal flavors, so pick what you want.
Sublime Text 2 already supports syntax highlighting for a lot of languages. I'm going to install a couple that are missing:
$ cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/
$ git clone https://github.com/jashkenas/coffee-script-tmbundle CoffeeScript
$ git clone https://github.com/miksago/jade-tmbundle Jade
$ git clone https://github.com/danro/LESS-sublime.git LESS
$ git clone -b SublimeText2 https://github.com/kuroir/SCSS.tmbundle.git SCSS
$ git clone https://github.com/nrw/sublime-text-handlebars Handlebars
Let's create a shortcut so we can launch Sublime Text from the command-line:
$ cd ~
$ mkdir bin
$ ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl
Now I can open a file with $ subl myfile.py or start a new project in the current directory with $ subl .. Pretty cool.
Sublime Text is very extensible. For now we'll leave it like that, we already have a solid installation. To add more in the future, a good place to start would be to install the Sublime Package Control.
Although Sublime Text will be our main editor, it is a good idea to learn some very basic usage of Vim. It is a very popular text editor inside the terminal, and is usually pre-installed on any Unix system.
For example, when you run a Git commit, it will open Vim to allow you to type the commit message.
I suggest you read a tutorial on Vim. Grasping the concept of the two "modes" of the editor, Insert (by pressing i) and Normal (by pressing Esc to exit Insert mode), will be the part that feels most unnatural. After that it's just remembering a few important keys.
Vim's default settings aren't great, and you could spend a lot of time tweaking your configuration (the .vimrc file). But if you're like me and just use Vim occasionally, you'll be happy to know that Tim Pope has put together some sensible defaults to quickly get started.
First, install pathogen.vim by running:
$ mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
Then create a file ~/.vimrc (you can use $ subl ~/.vimrc), and paste in the following:
execute pathogen#infect()
syntax on
filetype plugin indent on
And finally, install the Vim "sensible defaults" by running:
$ cd ~/.vim/bundle
$ git clone git://github.com/tpope/vim-sensible.git
With that, Vim will look a lot better next time you open it!
OS X, like Linux, ships with Python already installed. But you don't want to mess with the system Python (some system tools rely on it, etc.), so we'll install our own version with Homebrew. It will also allow us to get the very latest version of Python 2.7.
The following command will install Python 2.7 and any dependencies required (it can take a few minutes to build everything):
$ brew install python
When finished, you should get a summary in the terminal. Running $ which python should output /usr/local/bin/python.
It also installed Pip (and its dependency Distribute), which is the package manager for Python. Let's upgrade them both:
$ pip install --upgrade distribute
$ pip install --upgrade pip
Executable scripts from Python packages you install will be put in /usr/local/share/python, so let's add it to the $PATH. To do so, we'll create a .path text file in the home directory (I've already set up .bash_profile to call this file):
$ cd ~
$ subl .path
And add these lines to .path:
PATH=/usr/local/share/python:$PATH
export PATHSave the file and open a new terminal to take the new $PATH into account (everytime you open a terminal, .bash_profile gets loaded).
Here are a couple Pip commands to get you started. To install a Python package:
$ pip install <package>
To upgrade a package:
$ pip install --upgrade <package>
To see what's installed:
$ pip freeze
To uninstall a package:
$ pip uninstall <package>
Virtualenv is a tool that creates an isolated Python environment for each of your projects. For a particular project, instead of installing required packages globally, it is best to install them in an isolated folder in the project (say a folder named venv), that will be managed by virtualenv.
The advantage is that different projects might require different versions of packages, and it would be hard to manage that if you install packages globally. It also allows you to keep your global /usr/local/lib/python2.7/site-packages folder clean, containing only critical or big packages that you always need (like IPython, Numpy).
To install virtualenv, simply run:
$ pip install virtualenv
Let's say you have a project in a directory called myproject. To set up virtualenv for that project:
$ cd myproject/
$ virtualenv venv --distribute
If you want your virtualenv to also inherit globally installed packages (like IPython or Numpy mentioned above), use:
$ virtualenv venv --distribute --system-site-packages
These commands create a venv subdirectory in your project where everything is installed. You need to activate it first though (in every terminal where you are working on your project):
$ source venv/bin/activate
You should see a (venv) appear at the beginning of your terminal prompt indicating that you are working inside the virtualenv. Now when you install something:
$ pip install <package>
It will get installed in the venv folder, and not conflict with other projects.
Important: Remember to add venv to your project's .gitignore file so you don't include all of that in your source code!
As mentioned earlier, I like to install big packages (like Numpy), or packages I always use (like IPython) globally. All the rest I install in a virtualenv.
IPython is an awesome project which provides a much better Python shell than the one you get from running $ python in the command-line. It has many cool functions (running Unix commands from the Python shell, easy copy & paste, creating Matplotlib charts in-line, etc.) and I'll let you refer to the documentation to discover them.
Before we install IPython, we'll need to get some dependencies. Run the following:
$ brew update # Always good to do
$ brew install zeromq # Necessary for pyzmq
$ brew install pyqt # Necessary for the qtconsole
It may take a few minutes to build these.
Once it's done, we can install IPython with all the available options:
$ pip install ipython[zmq,qtconsole,notebook,test]
You can launch IPython from the command line with $ ipython, but what's more interesting is to use its QT Console. Launch the QT Console by running:
$ ipython qtconsole
You can also customize the font it uses:
$ ipython qtconsole --ConsoleWidget.font_family="Consolas" --ConsoleWidget.font_size=13
And since I'm lazy and I don't want to type or copy & paste that all the time, I'm going to create an alias for it. Create a .extra text file in your home directory with $ subl ~/.extra (I've set up .bash_profile to load .extra), and add the following line:
alias ipy='ipython qtconsole --ConsoleWidget.font_family="Consolas" --ConsoleWidget.font_size=13'Open a fresh terminal. Now when you run $ ipy, it will launch the QT Console with your configured options.
To use the in-line Matplotlib functionality (nice for scientific computing), run $ ipy --pylab=inline.
The Numpy and Scipy scientific libraries for Python are always a little tricky to install from source because they have all these dependencies they need to build correctly. Luckily for us, Samuel John has put together some Homebrew formulae to make it easier to install these Python libraries.
First, grab the special formulae (which are not part of Homebrew core):
$ brew tap samueljohn/python
$ brew tap homebrew/science
Then, install the gfortran dependency (now in gcc) which we will need to build the libraries:
$ brew install gcc
Finally, you can install Numpy and Scipy with:
$ brew install numpy
$ brew install scipy
(It may take a few minutes to build.)
We will install MySQL using Homebrew, which will also install some header files needed for MySQL bindings in different programming languages (MySQL-Python for one).
To install, run:
$ brew update # Always good to do
$ brew install mysql
As you can see in the ouput from Homebrew, before we can use MySQL we first need to set it up with:
$ unset TMPDIR
$ mkdir /usr/local/var
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
To start the MySQL server, use the mysql.server tool:
$ mysql.server start
To stop it when you are done, run:
$ mysql.server stop
You can see the different commands available for mysql.server with:
$ mysql.server --help
To connect with the command-line client, run:
$ mysql -uroot
(Use exit to quit the MySQL shell.)
Note: By default, the MySQL user root has no password. It doesn't really matter for a local development database. If you wish to change it though, you can use $ mysqladmin -u root password 'new-password'.
In terms of a GUI client for MySQL, I'm used to the official and free MySQL Workbench. But feel free to use whichever you prefer.
You can find the MySQL Workbench download here. (Note: It will ask you to sign in, you don't need to, just click on "No thanks, just start my download!" at the bottom.)
Install Node.js with Homebrew:
$ brew update
$ brew install node
The formula also installs the npm package manager. However, as suggested by the Homebrew output, we need to add /usr/local/share/npm/bin to our path so that npm-installed modules with executables will have them picked up.
To do so, add this line to your ~/.path file, before the export PATH line:
PATH=/usr/local/share/npm/bin:$PATHOpen a new terminal for the $PATH changes to take effect.
We also need to tell npm where to find the Xcode Command Line Tools, by running:
$ sudo xcode-select -switch /usr/bin
(If Xcode Command Line Tools were installed by Xcode, try instead:)
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Node modules are installed locally in the node_modules folder of each project by default, but there are at least two that are worth installing globally. Those are CoffeeScript and Grunt:
$ npm install -g coffee-script
$ npm install -g grunt-cli
To install a package:
$ npm install <package> # Install locally
$ npm install -g <package> # Install globally
To install a package and save it in your project's package.json file:
$ npm install <package> --save
To see what's installed:
$ npm list # Local
$ npm list -g # Global
To find outdated packages (locally or globally):
$ npm outdated [-g]
To upgrade all or a particular package:
$ npm update [<package>]
To uninstall a package:
$ npm uninstall <package>
##JSHint
JSHint is a JavaScript developer's best friend.
If the extra credit assignment to install Sublime Package Manager was completed, JSHint can be run as part of Sublime Text.
Install JSHint via npm (global install preferred)
$ npm install -g jshint
Follow additional instructions on the JSHint Package Manager page or build it manually.
Like Python, Ruby is already installed on Unix systems. But we don't want to mess around with that installation. More importantly, we want to be able to use the latest version of Ruby.
When installing Ruby, best practice is to use RVM (Ruby Version Manager) which allows you to manage multiple versions of Ruby on the same machine. Installing RVM, as well as the latest version of Ruby, is very easy. Just run:
$ curl -L https://get.rvm.io | bash -s stable --ruby
When it is done, both RVM and a fresh version of Ruby 2.0 are installed. The following line was also automatically added to your .bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*I prefer to move that line to the .extra file, keeping my .bash_profile clean. I suggest you do the same.
After that, start a new terminal and run:
$ type rvm | head -1
You should get the output rvm is a function.
The following command will show you which versions of Ruby you have installed:
$ rvm list
The one that was just installed, Ruby 2.0, should be set as default. When managing multiple versions, you switch between them with:
$ rvm use system # Switch back to system install (1.8)
$ rvm use 2.0.0 --default # Switch to 2.0.0 and sets it as default
Run the following to make sure the version you want is being used (in our case, the just-installed Ruby 1.9.3):
$ which ruby
$ ruby --version
You can install another version with:
$ rvm install 1.9.3
To update RVM itself, use:
$ rvm get stable
RubyGems, the Ruby package manager, was also installed:
$ which gem
Update to its latest version with:
$ gem update --system
To install a "gem" (Ruby package), run:
$ gem install <gemname>
To install without generating the documentation for each gem (faster):
$ gem install <gemname> --no-document
To see what gems you have installed:
$ gem list
To check if any installed gems are outdated:
$ gem outdated
To update all gems or a particular gem:
$ gem update [<gemname>]
RubyGems keeps old versions of gems, so feel free to do come cleaning after updating:
$ gem cleanup
I mainly use Ruby for the CSS pre-processor Compass, which is built on top of Sass:
$ gem install compass --no-document
CSS preprocessors are becoming quite popular, the most popular processors are LESS and SASS. Preprocessing is a lot like compiling code for CSS. It allows you to reuse CSS in many different ways. Let's start out with using LESS as a basic preprocessor, it's used by a lot of popular CSS frameworks like Bootstrap.
To install LESS you have to use NPM / Node, which you installed earlier using Homebrew. In the terminal use:
$ npm install less --global
Note: the --global flag is optional but it prevents having to mess around with file paths. You can install without the flag, just know what you're doing.
You can check that it installed properly by using:
$ lessc --version
This should output some information about the compiler:
lessc 1.5.1 (LESS Compiler) [JavaScript]
Okay, LESS is installed and running. Great!
There's a lot of different ways to use LESS. Generally I use it to compile my stylesheet locally. You can do that by using this command in the terminal:
$ lessc template.less template.css
The two options are the "input" and "output" files for the compiler. The command looks in the current directory for the LESS stylesheet, compiles it, and outputs it to the second file in the same directory. You can add in paths to keep your project files organized:
$ lessc less/template.less css/template.css
Read more about LESS on their page here: http://lesscss.org/
Heroku, if you're not already familiar with it, is a Platform-as-a-Service (PaaS) that makes it really easy to deploy your apps online. There are other similar solutions out there, but Heroku was among the first and is currently the most popular. Not only does it make a developer's life easier, but I find that having Heroku deployment in mind when building an app forces you to follow modern app development best practices.
Assuming that you have an account (sign up if you don't), let's install the Heroku Client for the command-line. Heroku offers a Mac OS X installer, the Heroku Toolbelt, that includes the client. But for these kind of tools, I prefer using Homebrew. It allows us to keep better track of what we have installed. Luckily for us, Homebrew includes a heroku-toolbelt formula:
$ brew install heroku-toolbelt
The formula might not have the latest version of the Heroku Client, which is updated pretty often. Let's update it now:
$ heroku update
Don't be afraid to run heroku update every now and then to always have the most recent version.
Login to your Heroku account using your email and password:
$ heroku login
If this is a new account, and since you don't already have a public SSH key in your ~/.ssh directory, it will offer to create one for you. Say yes! It will also upload the key to your Heroku account, which will allow you to deploy apps from this computer.
If it didn't offer create the SSH key for you (i.e. your Heroku account already has SSH keys associated with it), you can do so manually by running:
$ mkdir ~/.ssh
$ ssh-keygen -t rsa
Keep the default file name and skip the passphrase by just hitting Enter both times. Then, add the key to your Heroku account:
$ heroku keys:add
Once the key business is done, you're ready to deploy apps! Heroku has a great Getting Started guide, so I'll let you refer to that (the one linked here is for Python, but there is one for every popular language). Heroku uses Git to push code for deployment, so make sure your app is under Git version control. A quick cheat sheet (if you've used Heroku before):
$ cd myapp/
$ heroku create myapp
$ git push heroku master
$ heroku ps
$ heroku logs -t
The Heroku Dev Center is full of great resources, so be sure to check it out!
MongoDB is a popular NoSQL database.
Installing it is very easy through Homebrew:
$ brew update
$ brew install mongo
In a terminal, start the MongoDB server:
$ mongod
In another terminal, connect to the database with the Mongo shell using:
$ mongo
I'll let you refer to MongoDB's Getting Started guide for more!
Redis is a blazing fast, in-memory, key-value store, that uses the disk for persistence. It's kind of like a NoSQL database, but there are a lot of cool things that you can do with it that would be hard or inefficient with other database solutions. For example, it's often used as session management or caching by web apps, but it has many other uses.
To install Redis, use Homebrew:
$ brew update
$ brew install redis
Start a local Redis server using the default configuration settings with:
$ redis-server
For advanced usage, you can tweak the configuration file at /usr/local/etc/redis.conf (I suggest making a backup first), and use those settings with:
$ redis-server /usr/local/etc/redis.conf
In another terminal, connect to the server with the Redis command-line interface using:
$ redis-cli
I'll let you refer to Redis' documentation or other tutorials for more information.
As it says on the box, Elasticsearch is a "powerful open source, distributed real-time search and analytics engine". It uses an HTTP REST API, making it really easy to work with from any programming language.
You can use elasticsearch for such cool things as real-time search results, autocomplete, recommendations, machine learning, and more.
Elasticsearch runs on Java, so check if you have it installed by running:
java -versionIf Java isn't installed yet, a window will appear prompting you to install it. Go ahead and click "Install".
Next, install elasticsearch with:
$ brew install elasticsearchNote: Elasticsearch also has a plugin program that gets moved to your PATH. I find that too generic of a name, so I rename it to elasticsearch-plugin by running (will need to do that again if you update elasticsearch):
$ mv /usr/local/bin/plugin /usr/local/bin/elasticsearch-pluginBelow I will use elasticsearch-plugin, just replace it with plugin if you haven't followed this step.
As you guessed, you can add plugins to elasticsearch. A popular one is elasticsearch-head, which gives you a web interface to the REST API. Install it with:
$ elasticsearch-plugin --install mobz/elasticsearch-headStart a local elasticsearch server with:
$ elasticsearch -f(The -f option tells it to run in the foreground, so you can stop it with Ctrl+C.)
Test that the server is working correctly by running:
$ curl -XGET 'http://localhost:9200/'If you installed the elasticsearch-head plugin, you can visit its interface at http://localhost:9200/_plugin/head/.
Elasticsearch's documentation is more of a reference. To get started, I suggest reading some of the blog posts linked on this StackOverflow answer.
This really depends on how you want to organize your files, but I like to put all my version-controlled projects in ~/Projects. Other documents I may have, or things not yet under version control, I like to put in ~/Dropbox (if you have Dropbox installed), or ~/Documents.
Here is a quick list of some apps I use, and that you might find useful as well:
- Dropbox: File syncing to the cloud. I put all my documents in Dropbox. It syncs them to all my devices (laptop, mobile, tablet), and serves as a backup as well! (Free for 2GB)
- Google Drive: File syncing to the cloud too! I use Google Docs a lot to collaborate with others (edit a document with multiple people in real-time!), and sometimes upload other non-Google documents (pictures, etc.), so the app comes in handy for that. (Free for 5GB)
- 1Password: Allows you to securely store your login and passwords. Even if you only use a few different passwords (they say you shouldn't!), this is really handy to keep track of all the accounts you sign up for! Also, they have a mobile app so you always have all your passwords with you (syncs with Dropbox). A little pricey though. There are free alternatives. ($50 for Mac app, $18 for iOS app)
- Marked: As a developer, most of the stuff you write ends up being in Markdown. In fact, this
README.mdfile (possibly the most important file of a GitHub repo) is indeed in Markdown, written in Sublime Text, and I use Marked to preview the results everytime I save. ($4) - Path Finder: I love OSX, it's Unix so great for developers, and all of it just works and looks pretty! Only thing I "miss" from Windows (OMG what did he say?), is a decent file explorer. I think Finder is a pain to use. So I gladly paid for this alternative, but I understand others might find it expensive just to not have to use Finder. ($40)
- Evernote: If I don't write something down, I'll forget it. As a developer, you learn so many new things every day, and technology keeps changing, it would be insane to want to keep it all in your head. So take notes, sync them to the cloud, and have them on all your devices. To be honest, I switched to Simplenote because I only take text notes, and I got tired of Evernote putting extra spaces between paragraphs when I copy & pasted into other applications. Simplenote is so much better for text notes (and it supports Markdown!). (Both are free)
- Moom: Don't waste time resizing and moving your windows. Moom makes this very easy. ($10)