This document describes how I set up environment on a new MacBook or iMac. Thanks to nicolashery for reference to start with .
The steps below were tested on OS X El Capitan
- System update
- System preferences
- Google Chrome
- iTerm2
- Homebrew
- Beautiful terminal
- Git
- Sublime Text
- Vim
- Python
- Virtualenv
- IPython
- Numpy and Scipy
- MySQL
- Node.js
- JSHint Not required
- Ruby and RVM
- LESS Not required
- Heroku Not required
- AWSCLI
- MongoDB
- Redis
- Elasticsearch
- Projects folder
- Apps
First thing you need to do, on any OS actually, is update the system! For that: Apple Icon > About This Mac > Software Update...
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)
- Dock > Uncheck magnification and optimize the size
Install chrome though it eats up the RAM. Safari is not compatible with few websites due to few updates of El Capitan
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. Newest stable build is 3.0.5
In Finder, drag and drop the iTerm Application file into the Applications folder.
You can now launch iTerm, through the Launchpad for instance.
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.
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.
An important dependency before Homebrew can work is the Command Line Tools for Xcode. These include compilers that will allow you to build things from source.
Now, Xcode weights something like 2GB, and you don't need it unless you're developing iPhone or Mac apps. Good news is Apple provides a way to install only the Command Line Tools, without Xcode. To do this you need to go to http://developer.apple.com/downloads, and sign in with your Apple ID (the same one you use for iTunes and app purchases). Unfortunately, you're greeted by a rather annoying questionnaire. All questions are required, so feel free to answer at random.
Once you reach the downloads page, search for "command line tools", and download the latest Command Line Tools (OS X Mountain Lion) for Xcode. Open the .dmg file once it's done downloading, and double-click on the .mpkg installer to launch the installation. When it's done, you can unmount the disk in Finder.
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
Note: I've seen that command fail sometimes because of a bug. If that ever happens, run the following (when you have Git installed):
$ cd /usr/local
$ git fetch origin
$ git reset --hard origin/master
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 do some cleanup to get rid of those old versions:
$ brew cleanup
To see what you have installed (with their version numbers):
$ brew list --versions
Since we spend so much time in the terminal, we should try to make it a more pleasant and colorful place.
Let's go ahead and start by changing the font. In iTerm > Preferences..., under the tab Profiles, section Text, change both fonts to Source code pro 14pt.
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.
- Install ohmyzsh on the terminal OhmyZsh. It contains lot of plugins and themes
- Edit .zshrc in home directory and change the theme to garyblessington or gozilla . I like both of them
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.
Now we have a terminal we can work with!
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
.
Next, we'll define your Git user (should be the same name and email you use for GitHub:
$ git config --global user.name "Your Name Here"
$ git config --global user.email "[email protected]"
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.
$ git config --global core.excludesfile '~/.gitignore'
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.
Just like the terminal, let's configure our editor a little.
For the Color Scheme (the colors of the code), i use solarized dark . I'm going to change the Theme (which is how the tabs, the file explorer on the left, etc. look) . Again, feel free to pick different ones, or stick with the default.
A popular Theme is the Soda Theme. To install it, run :
$ git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"
Copy the Theme-Soda folder and go to Sublime Text > Preferences > Browse Packages.. . Paste the Theme-Soda folder to the folder.
The Soda Theme page also offers some extra color schemes you can download and try. Solarized Color Scheme is good, which already ships with Sublime Text. To use it, just go to Sublime Text > Preferences > Color Scheme > Solarized (Dark).
Create a shortcut so we can launch Sublime Text from the command-line:
$ ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Now I can open a file with $ subl myfile.py
.
Sublime Text is very extensible. We need to install few things to make it more comfortable working with python.
First install Sublime Package Control. After installing it , install the following packages by using package control manager.
- Anaconda
- Git
- GitGutter
- SublimeLinter-pep8
- SublimeLinter-pyflakes
- Theme - Soda
- Theme - Soda SolarizedDark
Finally go to Sublime Text > Preferences > Settings - User and copy the contents from dotfiles/sublime-settings-user.json Feel free to tweak these to your preference. When done, save the file and close it. Restart Sublime Text for all changes to take effect.
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.
Vim's default settings aren't great, and you could spend a lot of time tweaking your configuration (the .vimrc
file).
My Vim configuration steps are below:
First, install vim package manager vundle by running: $ git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
Then create a file ~/.vimrc
and add the contents of .vimrc
in dotfiles directory.After copying the contents,
install the plugins mentioned in .vimrc
file by executing :PluginInstall
.
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 PATH
Save 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!
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
$ pip install qtconsole
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
Y
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:$PATH
Open 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 Not required
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 .zshrc
. If not please add it.
[[ -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!
AWSCLI is required for making API requests to AWS apart from boto3 to test the features.
###Install
Installing is very easy through pip :
$ pip install awscli
$ pip install boto3
###Configuration
AWS configuration files:
- .aws/config can have mutiple profiles to select the regions and output format . Sample contents:
[default]
output = text
region = us-east-1
[profile OWN]
output = text
region = us-west-2
- .aws/credential can have mutiple profiles similar to config file. This file contains the AWS keys.
[default]
aws_access_key_id =
aws_secret_access_key =
aws ec2 describe-instances - Will list the ec2 instances as per the configuration
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 -version
If 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 elasticsearch
Note: 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-plugin
Below 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-head
Start 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 ~/git
. 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.
- 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! and sometimes upload other non-Google documents (pictures, etc.), so the app comes in handy for that. (Free for 5GB)
- Evernote : Take notes and sync them to the cloud, and have them on all your devices. I use Notes for text that are not be synced . You may also like Simplenote. Simplenote is so much better for text notes (and it supports Markdown!). (Both are free)
- AdobeReader: Though i like preview for document viewing , i prefer using adobe reader for all my PDF docuements . Dont forget to set the default app for PDF files to adobe reader.**Right click on file -> Get info -> Open with **
- Slack : Used in almost all organizations for internal team collobration.
- Mou : For writing files in markdown syntax. Similar to simplenote , but i started using this first.
- Keka : Tar/zip file extraction though inbuilt archive utility works
- OpenOffice : If you are editing any microsoft office documents/Ppts . Open Source
- WireShark : For analyzing the network data
- TunnelBlick : For VPN connectivity
- TunnelBear : Similar to TunnelBlick . But never used it.
- OracleVirtualBox : To create local VM's for testing . Opensource
- MicrosoftSilverLight : Some of the websites/apps require this extension to be installed
- MozillaFirefox
- Docker
- Postman
I have few personal apps installed as well for daily use.