Skip to content

Instantly share code, notes, and snippets.

@bhubr
Last active September 3, 2019 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhubr/c037ca57daa03074b4cff72ffb23228d to your computer and use it in GitHub Desktop.
Save bhubr/c037ca57daa03074b4cff72ffb23228d to your computer and use it in GitHub Desktop.
Setup MacOS for web development

Development Environment Setup on MacOS

We're going to install and configure essential (and not-so-essential) tools for web development on MacOS.

MacOS being a Unix derivative, and the Open Source community being very active, you can get all the tools that make Linux a great OS for development.

If you want to go further, take a look at:

General

Finder customization

  • Open Finder on Home folder
  • Home and Code shortcuts in sidebar
  • Customize dock (terminal as favorite, hide dock, etc.)

Terminal settings

  • A well-designed, balanced color theme makes working in the terminal nicer: Oceanic Next is quite popular (you can also find it for Sublime Text and Visual Studio Code).
  • Disable sound bell
  • Adjust default font size

Install common software via Homebrew

Install Homebrew and Cask:

  • Homebrew is a package manager that allows to easily install programs from the command-line.
  • Cask is its extension dedicated to graphical applications.

Paste this into your terminal to install Homebrew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Press RETURN when asked for.

Once it's done, paste this to install Cask:

brew tap caskroom/cask

Install Git, Bash Completions, GNU Coreutils, MySQL via Homebrew

  • Git is the well-known code-versioning software
  • Bash Completions bings nice auto-completion features to the shell
  • Coreutils are the essential GNU tools (ls, etc.), which are better than the ones shipped with MacOS
  • MySQL is a commonly used Database Management System

You can use brew install followed by any number of package names to install more than one piece of software at once.

brew install git bash-completion tree wget coreutils mysql@5.7

Use brew search <keyword> to find suggestions for other software (replace <keyword> with anything, e.g. mp3, etc.).

Install browsers, editors and other tools

  • As for browsers, you'll probably need both Mozilla Firefox and Google Chrome, and might want to give Brave a try
  • You can pick one of Visual Studio Code, Atom, Sublime Text, etc, Sequel Pro via Cask

Just like brew, brew cask allows you to install many packages with a single command: This installs Firefox, Chrome, Brave and Visual Studio Code (you might skip this one until you start studying databases):

brew cask install firefox google-chrome visual-studio-code

General post-install configuration

VSCode

  • Disable "commit characters"
  • Set tab size according to the language
  • Install extensions (Live Server, etc.)

Git

  • Username / Email
  • Default editor
  • Global .gitignore

Bash completions

Two files have to be created:

  • .bashrc
  • .bash_profile

This step can be automated!

Just open your terminal, then paste this:

curl https://gist.githubusercontent.com/bhubr/c037ca57daa03074b4cff72ffb23228d/raw/677c96093f9c9af345dbdb74b9168cb1b143f1f2/sample.bashrc -o ~/.bashrc
curl https://gist.githubusercontent.com/bhubr/c037ca57daa03074b4cff72ffb23228d/raw/677c96093f9c9af345dbdb74b9168cb1b143f1f2/sample.bash_profile -o ~/.bash_profile
chmod 700 ~/.bashrc
chmod 700 ~/.bash_profile

Then RESTART your machine (otherwise most of Bash&Git config just won't work).

Language-specific

  • PHP (Homebrew)
    • Apache or Nginx
  • MySQL
    • phpMyAdmin (Apache or Nginx + PHP)
  • Java (Oracle JVM via Cask)
  • Node.js (not via brew but via NVM)
  • Install Devdocs.io locally - requires Ruby, see instructions
## Exec bashrc
if [ -r ~/.bashrc ]; then
source ~/.bashrc
fi
# Sources
# https://github.com/bobthecow/git-flow-completion/wiki/Install-Bash-git-completion
# https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh
# https://delicious-insights.com/fr/articles/prompt-git-qui-dechire/
# https://github.com/matthewmccullough/dotfiles/blob/master/bash_gitprompt
[ -f /usr/local/etc/bash_completion ] && source /usr/local/etc/bash_completion
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
BLUE="\[\033[0;34m\]"
LIGHT_RED="\[\033[1;31m\]"
LIGHT_GREEN="\[\033[1;32m\]"
WHITE="\[\033[1;37m\]"
LIGHT_GRAY="\[\033[0;37m\]"
COLOR_NONE="\[\e[0m\]"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="${BLUE}[\u@\h] ${LIGHT_GREEN}\w${LIGHT_RED}\$(__git_ps1) ${COLOR_NONE}\$ "
## Aliases for GNU coreutils (brew install coreutils) ##
alias ls='gls --color=auto'
alias cp=gcp
alias rm=grm
alias mv=gmv
alias chown=gchown
alias chmod=gchmod
alias mkdir=gmkdir
alias rmdir=grmdir
## Use a long listing format ##
alias ll='ls -la'
## Show hidden files ##
alias l.='ls -d .* --color=auto'
## Set PATH
export PATH="/usr/local/opt/mysql@5.7/bin:$PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment