Skip to content

Latest commit

 

History

History
316 lines (248 loc) · 11 KB

mac-os_thru_2021.md

File metadata and controls

316 lines (248 loc) · 11 KB

How To Setup a Mac Development Environment (from scratch)

Should be considered out-of-date but still relevant overall.

Table of Contents

Assumptions

  • Mac OS X 10.10.4+
  • Dropbox
  • Sublime Text 3
  • You're logged in as an administrative user of the computer.
  • You want Python 2.7.x (2.7 is end of life, upgrade to 3!)
  • You have a VPN already

Basic Configuration

  • Github for Mac [ Source ]
  • Unhide Library Folder
    • Open Finder.
    • 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.
  • Bash Profile Setup
    • vim ~/.bash_profile
# Finder: show hidden files
defaults write com.apple.finder AppleShowAllFiles TRUE

# Always use colour output for ls.
[[ "$OSTYPE" =~ ^darwin ]] && alias ls='command ls -G' || alias ls='command ls --color';

######ALIASES###############
alias sublime='open -a "Sublime Text 2"'
alias reload='source ~/.bash_profile'
alias edit_profile='vim ~/.bash_profile'

######EXPORT#############
export EDITOR=sublime

export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin

# Ignore duplicate commands in the history
export HISTCONTROL=ignoredups
# Increase the maximum number of lines contained in the history file
# (default is 500)
export HISTFILESIZE=10000
# Increase the maximum number of commands to remember
# (default is 500)
export HISTSIZE=10000
# Make new shells get the history lines from all previous
# shells instead of the default "last window closed" history
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# Append to the Bash history file, rather than overwriting it
shopt -s histappend;

export WORKON_HOME=~/Envs
export PROJECT_HOME=~/Envs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTULENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
* `source ~/.bash_profile`
  • Get the XCode pieces you need
    • xcode-select --install
    • Will prompt for full version of Xcode or just command line tools

Back to TOC

Mac OS Configuration

  • Change background of login screen Lifehacker article If you're running Yosemite, all you need to do is save your desired image as: /Library/Caches/com.apple.desktop.admin.png.

Package Managers

import urllib.request,os,hashlib; h = 'df21e130d211cfc94d9b0905775a7c0f' + '1e3d39e33b79698005270310898eea76'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

Default Sublime Packages

{
	"auto_complete_triggers":
	[
		{
			"characters": "b4",
			"selector": "text.html"
		}
	],
	"font_size": 15,
	"ignored_packages":
	[
		"Vintage"
	]
}

Sublime Text 3 Only

Back to TOC

Local Databases

mySQL

mysql -v
brew install mysql
mysql -v
mysql -uroot

# mysql-5.7.19.sierra.bottle.tar.gz as of this writing

#We've installed your MySQL database without a root password. To secure it run:
#    mysql_secure_installation

#MySQL is configured to only allow connections from localhost by default

#To connect run:
#    mysql -uroot

#To have launchd start mysql now and restart at login:
#  brew services start mysql
#Or, if you don't want/need a background service you can just run:
#  mysql.server start

Postgresql

Back to TOC

Python Specific Environment

Virtual Environment

Asssumes the variables for virtualenv listed in the ~/.bash_profile above. Uses virtualenvwrapper to - you guessed it - wrap virtualenv.

pip install virtualenv
pip install --ignore-installed six #handles six upgrade error
pip install virtualenvwrapper
export WORKON_HOME=~/Envs
source /usr/local/bin/virtualenvwrapper.sh
  • Close Terminal and Re-open Terminal.
  • cd to your directory
  • mkvirtualenv venv
  • workon venv

Sublime Python Packages

Python Libraries

Python Web Frameworks

Flask

Django

Back to TOC

Docker

Other Helpful Tools

Back to TOC

Out-of-Date 2021

Dev

  • Start the Xcode download/updates first through the App Store. This takes awhile. (you can download only the part you need with the CLI command above.)

Sublime Packages - Optional/Don't Use in 2021

Ruby Specific Environment - Out-of-Date

Ruby Version Manager (RVM)

  • You may need to brew install gnupg gnupg2 first so the gpg key can be installed.

  • To solve the errors from this:

    • sudo chown -R $(whoami) /usr/local/lib
    • brew link libgpg-error
    • brew link libassuan
    • brew link libgcrypt
    • brew link libksba
    • brew link libusb
    • brew link libusb-compat
    • brew link pth
  • brew doctor can be helpful as well.

  • Install

    • gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
    • \curl -sSL https://get.rvm.io | bash -s stable
    • source /Users/{username}/.rvm/scripts/rvm (replace {username})
    • rvm install 2.2.4 (or latest stable release version on this page Ruby)
    • rvm use 2.2.4
    • You may also want ruby -v or which ruby.
  • Link to RVM for niceness sake, but avoid reading their docs at all costs. They are horrible.

Gems

  • Postgresql = gem install pg
  • Cheatset = gem install cheatset

Make cheat sheets for Dash.

Ruby Web Frameworks

Rails

Here are commands I've used in getting started on a rails project setup. Don't run unless you understand them.

Back to TOC

Other