Skip to content

Instantly share code, notes, and snippets.

@cklanac
Last active February 26, 2024 04:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cklanac/a5256fcc87ba81f680d621b338dfd625 to your computer and use it in GitHub Desktop.
Save cklanac/a5256fcc87ba81f680d621b338dfd625 to your computer and use it in GitHub Desktop.
Mac setup

Mac Setup Distilled

Install Chrome, Dev and Canary

Description of Chrome Channels

  • Install Chrome or Chrome Dev
    • Note: Chrome and Chrome Dev use the same profile on a Mac
  • Setup 2 profiles:
    • Browsing: It may contain bookmarks, personal settings and extenstions
    • Development: It should only be minimal, only have React, Redux and dev related extenstions
  • Install Chrome Canary for future feature testing

Install command line apps

Install HomeBrew

From your terminal

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

Note: brew needs Xcode Command Line Tools to be compiled so you may see the following request:

==> The Xcode Command Line Tools will be installed.

Press RETURN to continue or any other key to abort

Install Node 10 LTS

From your terminal, brew install the following:

Note: As of June 2019, Node Debugger (NDB) does support Node 12.x, yet. So install Node 10 and sym

Install Node:

brew install node@10 - installs node, npm and npx and adds symlinks to /usr/local/bin

Add to PATH:

echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile

Re-source .bask_profile:

source ~/.bash_profile

Install Git

You can install install git using Homebrew or the GUI

Install Git using Brew

brew install git - installs git, git-cvsserver, git-receive-pack, git-shell, git-upload-archive, git-upload-pack, gitk as well as pcre2-config, pcre2grep, pcre2test.

Install Git using GUI

Download and install git GUI from http://sourceforge.net/projects/git-osx-installer/ - This installs git to /usr/local/git, and places symlinks for git, git-credential-osxkeychain, git-cvsserver, git-shell and gitk as well as pcre2-config, pcre2grep, pcre2test into /usr/local/bin.

brew install postgres
brew install mongo 

Config Git

Setup git username and email address

  • In Terminal,
git config --global user.name "John Doe"
git config --global user.email johndoe@example.com

Access GitHub from Terminal

Git osxkeychain helper

The credential helper tells Git to remember your GitHub username and password in the OSX Keychain app. If you installed Git using Brew then the credential helper is already installed installed. Configure it below

  • On the Terminal,
git config --global credential.helper osxkeychain

Now you can use HTTPS git URLs instead of SSH. If you are using 2-Factor Authentication then you must use a Personal Access Token on the Terminal instead of your password. Setup a Personal Access Token below

Git Personal Access Token for 2-Factor Authentication

If you are 2FA you must use a Personal Access Token to login to GitHub from the terminal

On github.com:

  • Go to: Settings > Developer settings > Personal access tokens
  • Create an access token, copy the token
  • On the Terminal, make a commit and then push the change to a remote on GitHub.
  • Enter the Personal Access Token instead of your password

Note: the Personal Access Token will be saved in the OSX Keychain app

Install global NPM packages

Install common global NPM packages

  • brew install the following:
npm install -g eslint http-server nodemon 

Install Node Debugger

Install Chrome Labs Node Debugger

npm install -g ndb

Install Java JDK (for Android development)

Install Java JDK

  • Update brew
brew update
  • Retrieve casks info
brew tap homebrew/cask-versions
  • Install current Java JDK
brew cask install java

Configure apps

Configure a global ESLint

ESLint supports both global and local configurations so you can have eslintrc files in individual projects as well as at user root. The child configurations in the project folder take precedence over higher configurations. In your user root create the following file.

  • From your terminal:
    • cd to user root cd ~
    • touch eslintrc.json
    • add the following to the file
/** 
* ESLint: http://eslint.org/docs/user-guide/configuring
*/
{
	// https://eslint.org/docs/user-guide/configuring#specifying-parser
    "parserOptions": {
       "ecmaVersion": 7  //same as 2016
    },
    
    // https://eslint.org/docs/user-guide/configuring#specifying-environments
    "env": {
        "browser": true,
        "node": true,
        "es6": true,
        "mocha": true,
        "jest": true,
        "mongo": true,
        "jquery": true
    },

    // our configuration extends the recommended base configuration
    // https://eslint.org/docs/user-guide/configuring#extending-configuration-files
    "extends": "eslint:recommended",

	// https://eslint.org/docs/rules/
    // ESLint rules: Severity Levels: off = 0 | warn = 1 | error = 2
    "rules": {
        "strict": ["error", "safe"],   	//prefer `'use-strict';` pragma
        "eqeqeq": [2, "allow-null"],
        "no-console": "off",          	//ignores `console.log()`
        "no-unused-vars": ["warn", { "vars": "local", "args": "after-used", "ignoreRestSiblings": false }],
        "no-eval": "error",            	//disallows `eval()` usage
        "quotes": [2, "single", "avoid-escape"], //prefer single quotes over double quotes
        "indent": ["error", 2, {		// enforce 2 space indents (not tabs)
        	"SwitchCase": 1				// clauses with 2 spaces with respect to switch statements
        }],
        "semi": ["error", "always"]    //enforce semi-colon usage
    }
}

Configure Postgres PGDATA

Set the default PostgreSQL PGDATA directory

  • Add the following to your ~/.bash_profile file
touch ~/.bash_profile
echo 'export PGDATA=/usr/local/var/postgres' >> ~/.bash_profile

Install Development Apps

App Store Apps:

  • Magnet ($)
  • ScreenBrush
  • Chrom or Chrome Dev
  • Chrome Canary
  • Chrome Extensions for browsing
    • AdBlock
    • Open Frame
    • Thinkful sessions
  • Chrome Extensions for Development
    • JSON Viewer
    • React
  • Postman
  • Slack
  • System Monitor ($)

Other Apps

  • Dropbox
  • Google Drive

Optional Installs and Configs

OPTIONAL: Create a global gitignore

Git uses both local and global gitignore files. You can setup a global gitignore which will prevent common files from accidentally being committed to your repos.

  • From your terminal:
    • cd to user root cd ~
    • touch .gitignore
    • add the following configuration
######################
# REF: https://gist.github.com/octocat/9257657
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
 
# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip
 
# Logs and databases #
######################
*.log
# *.sql This should be committed for demos
*.sqlite
 
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

OPTIONAL: Configure command line completion

If you installed the above apps using brew, then you can setup command line completion for git, npm, brew,

#####
# (OPTIONAL) COMMAND LINE COMPLETION
# http://superuser.com/questions/31744/how-to-get-git-completion-bash-to-work-on-mac-os-x
#####
# Load bash completion for brew
if [ -f `brew --prefix`/etc/bash_completion.d/brew ]; then
    source `brew --prefix`/etc/bash_completion.d/brew
fi

# Load bash completion for git
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
	source `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi

# Load bash completion for NPM
if [ -f `brew --prefix`/etc/bash_completion.d/npm ]; then
    source `brew --prefix`/etc/bash_completion.d/npm
fi

OPTIONAL: Configure Git Prompt

Optionally, you can setup your prompt to show your git repository status

#####
# (OPTIONAL) GIT PROMPT SUPPORT 
# View the git-prompt.sh file for mor information
#####
# Load git prompt
if [ -f `brew --prefix`/etc/bash_completion.d/git-prompt.sh ]; then
    source `brew --prefix`/etc/bash_completion.d/git-prompt.sh
    PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
fi

Now you command prompt will looks something like this:

[user@MACHINE git-repository-name (master)]$ 

OPTIONAL: Chrome Configs

Disable swipe to go back

defaults write com.google.Chrome.plist AppleEnableSwipeNavigateWithScrolls -bool FALSE

OPTIONAL: Show Hidden Files

defaults write com.apple.finder AppleShowAllFiles YES

To hide them again, run ... AppleShowAllFiles NO

OPTIONAL: Change Dock Slide Out

  • Make dock slide-out very, very slowly so it doesn't get in the way
defaults write com.apple.dock autohide-delay -int 5; killall Dock;
  • Make dock slide-out instantly, if you like that kinda thing?!
defaults write com.apple.dock autohide-delay -int 0;
defaults write com.apple.dock autohide-time-modifier -int 0;
killall Dock;
  • Restore dock defaults
defaults delete com.apple.dock autohide-delay;
defaults delete com.apple.dock autohide-time-modifier;
killall Dock;

Reference:

Add an executable FOO to PATH

echo 'export PATH="/path/to/FOO:$PATH"' >> ~/.bash_profile

If foo is in /usr/local/bin/, then:

echo 'export PATH="/usr/local/bin/FOO:$PATH"' >> ~/.bash_profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment