Setting up a new developer machine can be an ad-hoc, manual, and time-consuming process.
mobile-dev-setup aims to simplify the process with easy-to-understand instructions and dotfiles/scripts to automate the setup for a mobile developer:
If you're interested in automation, mobile-dev-setup provides a customizable setup script. There's really no one-size-fits-all solution for developers so you're encouraged to make tweaks to suit your needs.
Credits: This repo builds on the awesome work from Donne Martin.
Scripts tested on OS X 10.10 Yosemite, 10.11 El Capitan & 10.12 Sierra.
~$ git clone https://github.com/donnemartin/dev-setup.git && cd dev-setup
Since you probably don't want to install every section, the .dots script supports command line arguments to run only specified sections. Simply pass in the scripts that you want to install. Below are some examples.
For more customization, you can clone or fork the repo and tweak the .dots script and its associated components to suit your needs.
Run all:
$ ./.dots all
Run bootstrap.sh, xcode-setup.sh, fresh-setup.sh, and osx-setup.sh:
$ ./.dots bootstrap xcode-setup fresh-setup osx-setup
$ curl -O https://raw.githubusercontent.com/donnemartin/dev-setup/master/.dots && ./.dots [Add ARGS Here]
~Notes:
.dots will initially prompt you to enter your password..dots might ask you to re-enter your password at certain stages of the installation..dots again to resume where you left off..dots runs fresh-setup.sh, which takes awhile to complete as some formulae need to be installed from source..dots completes, be sure to restart your computer for all updates to take effect.I encourage you to read through Section 1 so you have a better idea of what each installation script does. The following discussions describe in greater detail what is executed when running the .dots script.
The bootstrap.sh script will sync the mobile-dev-setup repo to your local home directory. This will include customizations for Vim, bash, curl, git, tab completion, aliases, a number of utility functions, etc. Section 2 of this repo describes some of the customizations.
First, fork or clone the repo. The bootstrap.sh script will pull in the latest version and copy the files to your home folder ~:
$ source bootstrap.sh
To update later on, just run that command again.
Alternatively, to update while avoiding the confirmation prompt:
$ set -- -f; source bootstrap.sh
To sync dev-setup to your local home directory without Git, run the following:
$ cd ~; curl -#L https://github.com/gurpreetsk95/mobile-dev-setup/tarball/master | tar -xzv --strip-components 1 --exclude={README.md,bootstrap.sh,LICENSE}
To update later on, just run that command again.
If ~/.path exists, it will be sourced along with the other files before any feature testing (such as detecting which version of ls is being used takes place.
Here’s an example ~/.path file that adds /usr/local/bin to the $PATH:
export PATH="/usr/local/bin:$PATH"If ~/.extra exists, it will be sourced along with the other files. You can use this to add a few custom commands without the need to fork this entire repository, or to add commands you don’t want to commit to a public repository.
You could also use ~/.extra to override settings, functions, and aliases from the dev-setup repository, although it’s probably better to fork the mobile-dev-setup repository.
Run the xcode-setup.sh script:
$ ./xcode-setup.sh
xcode-setup.sh will first install all updates. If a restart is required, simply run the script again. Once all updates are installed, xcode-setup.sh will then Install Xcode Command Line Tools.
If you want to go the manual route, you can also install all updates by running "App Store", selecting the "Updates" icon, then updating both the OS and installed apps.
An important dependency before many tools such as Homebrew can work is the Command Line Tools for Xcode. These include compilers like gcc that will allow you to build from source.
If you are running OS X 10.9 Mavericks or later, then you can install the Xcode Command Line Tools directly from the command line with:
$ xcode-select --install
Note: the xcode-setup.sh script executes this command.
Running the command above will display a dialog where you can either:
If you're running 10.8 or older, you'll 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.
When setting up a new Mac, you may want to install Homebrew, a package manager that simplifies installing and updating applications or libraries.
Some of the apps installed by the fresh-setup.sh script include: Chrome, Firefox, Sublime Text, Atom, Skype, Slack etc. For a full listing of installed formulae and apps, refer to the commented fresh-setup.sh source file directly and tweak it to suit your needs.
Run the fresh-setup.sh script:
$ ./fresh-setup.sh
The fresh-setup.sh script takes awhile to complete, as some formulae need to be installed from source.
For your terminal customization to take full effect, quit and re-start the terminal
When setting up a new Mac, you may want to set OS X defaults geared towards developers. The osx.sh script also configures common third-party apps such Sublime Text and Chrome.
Note: I strongly encourage you read through the commented osx-setup.sh source file and tweak any settings based on your personal preferences. The script defaults are intended for you to customize. For example, if you are not running an SSD you might want to change some of the settings listed in the SSD section.
Run the osx-setup.sh script:
$ ./osx-setup.sh
For your terminal customization to take full effect, quit and re-start the terminal.
To set up an Android development environment, run the android.sh script:
$ ./android-setup.sh
Section 3: Android Development describes the installed packages and usage.
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.
The fresh-setup.sh script installs Sublime Text.
If you prefer to install it separately, go ahead and download it. Open the .dmg file, drag-and-drop in the Applications folder.
Note: At this point I'm going to create a shortcut on the OS X Dock for both for Sublime Text. 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.
The osx-setup.sh script contains Sublime Text configurations.
The Soda Theme is a great UI theme for Sublime Text, especially if you use a dark theme and think the side bar sticks out like a sore thumb.
If you are using Will Bond's excellent Sublime Package Control, you can easily install Soda Theme via the Package Control: Install Package menu item. The Soda Theme package is listed as Theme - Soda in the packages list.
Alternatively, if you are a git user, you can install the theme and keep up to date by cloning the repo directly into your Packages directory in the Sublime Text application settings area.
You can locate your Sublime Text Packages directory by using the menu item Preferences -> Browse Packages....
While inside the Packages directory, clone the theme repository using the command below:
$ git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"
Sublime Text 2 -> Preferences -> Settings - User"theme": "Soda Light.sublime-theme" or "theme": "Soda Dark.sublime-theme"Example Sublime Text 2 User Settings
{
"theme": "Soda Light.sublime-theme"
}
Sublime Text -> Preferences -> Settings - User"theme": "Soda Light 3.sublime-theme" or "theme": "Soda Dark 3.sublime-theme"Example Sublime Text 3 User Settings
{
"theme": "Soda Light 3.sublime-theme"
}
Although Monokai is a great color scheme, I find that comments can be difficult to see. You can follow these instructions to change the color of the default theme.
I set my comments color to #E6DB74.
<dict>
...
<dict>
<key>foreground</key>
<string>#E6DB74</string>
</dict>
...
</dict>
Atom is a great open-source editor from GitHub that is rapidly gaining contributors and popularity.
The fresh-setup.sh script installs Atom.
If you prefer to install it separately, download it, open the .dmg file, drag-and-drop in the Applications folder.
Atom has a great package manager that allows you to easily install both core and community packages.
Since we spend so much time in the terminal, we should try to make it a more pleasant and colorful place.
The bootstrap.sh script and osx-setup.sh script contain terminal customizations.
I prefer iTerm2 over the stock Terminal, as it has some additional great features. Download and install iTerm2 (the newest version, even if it says "beta release").
In Finder, drag and drop the iTerm Application file into the Applications folder.
You can now launch iTerm, through the Launchpad for instance.
Let's just quickly change some preferences. In iTerm > Preferences..., 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. Under the section Window, change the size to something better, like Columns: 125 and Rows: 35. I also like to set General > Working Directory > Reuse previous session's directory. Finally, I change the way the option key works so that I can quickly jump between words as described here.
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.
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.
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.
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 "Donne's MacBook Pro" to just "MacBook Pro", so it shows up as MacBook-Pro in the terminal.
Now we have a terminal we can work with!
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.
The bootstrap.sh script contains Vim customizations.
What's a developer without Git?
Git should have been installed when you ran through the Install Xcode Command Line Tools section.
To check your version of Git, run the following command:
$ 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/donnemartin/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 "[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. Also check out GitHub's collection of .gitignore templates.
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.
The fresh-setup.sh script installs Homebrew and a number of useful Homebrew formulae and apps.
If you prefer to install it separately, run the following command and follow the steps on the screen:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
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
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.
fresh-setup.sh provides rbenv and ruby-build which allow you to manage multiple versions of Ruby on the same machine. fresh-setup.sh adds the following line to your .extra file to initialize rbenv:
eval "$(rbenv init -)"
rbenv uses ruby-build to download, compile, and install new versions of Ruby. You can see all versions available to download and install:
$ ruby-build --definitions
To install a new version of Ruby:
# list all available versions installed on the system:
$ rbenv install -l
# install a Ruby version:
$ rbenv install 2.2.3
To switch Ruby versions:
# set a local application-specific Ruby version in the current directory
$ rbenv local 1.9.3
# set the global version of Ruby to be used in all shells
$ rbenv global 2.0.0
rbenv by default will install Ruby versions into a directory of the same name under ~/.rbenv/versions. Because your user owns this directory, you no longer need to use sudo to install gems.
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 and Python 3.
The first-install.sh script installs the latest versions of Python 2 and Python 3.
The android-setup.sh script installs Java.
If you prefer to install it separately, you can download the JDK here or run:
$ brew update
$ brew install caskroom/cask/brew-cask
$ brew cask install --appdir="~/Applications" java
The android-setup.sh script installs the Android SDK.
If you prefer to install it separately, you can download it here.
The android-setup.sh script installs Android Studio.
If you prefer to install it separately, you can download it here or run:
$ brew update
$ brew install caskroom/cask/brew-cask
$ brew cask install --appdir="~/Applications" android-studio
The android-setup.sh script installs Java.
If you prefer to install it separately, you can download it here or run:
$ brew update
$ brew install caskroom/cask/brew-cask
$ brew cask install --appdir="~/Applications" intellij-idea-ce
Bug reports, suggestions, and pull requests are welcome!
See the Credits Page.
Feel free to contact me to discuss any issues, questions, or comments.
My contact info can be found on my GitHub page.
This repository contains a variety of content; some developed by Gurpreet Singh, and some from third-parties. The third-party content is distributed under the license provided by those parties.
The content developed by Gurpreet Singh is distributed under the following license:
I am providing code and resources in this repository to you under an open source license. Because this is my personal repository, the license you receive to my code and resources is from me and not my employer.
Copyright 2017 Gurpreet Singh
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.