| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | import os | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | from invoke import ctask | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | from . import util | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @ctask(default=True) | 
					
						
							|  |  |  | def all(ctx): | 
					
						
							|  |  |  |     get_command_line_tools(ctx) | 
					
						
							|  |  |  |     get_brew(ctx) | 
					
						
							| 
									
										
										
										
											2014-10-31 18:34:49 -07:00
										 |  |  |     cider_install(ctx) | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     enable_access_for_assistive_devices(ctx) | 
					
						
							| 
									
										
										
										
											2014-10-24 06:19:23 -07:00
										 |  |  |     enable_hyper(ctx) | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  |     enable_locate(ctx) | 
					
						
							| 
									
										
										
										
											2014-11-09 22:18:16 -08:00
										 |  |  |     install_rvm(ctx) | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  |     install_powerline_monaco(ctx) | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  |     osx_config(ctx) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ESSENTIAL = ( | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     "emacs --cocoa --srgb --with-x", "tmux", "python --with-brewed-openssl", | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  |     "htop", "zsh", "make", "scala",  "sbt", "node", "npm", "daemonize", | 
					
						
							|  |  |  |     "readline", "netcat", "reattach-to-user-namespace", "watch" | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  | BASICS = ( | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  |     "findutils", "coreutils", "binutils", "diffutils", "ed --default-names", | 
					
						
							|  |  |  |     "gawk", "gnu-indent --default-names", "gnu-sed --default-names", | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     "gnu-tar --default-names", "gnu-which --default-names", | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  |     "gnutls --default-names", "grep --default-names", "gzip", | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     "wdiff --with-gettext", "wget --enable-iri" | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | SHOULD_INSTALL = ( | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  |     "nmap", "ngrep", "gist", "gawk", "pstree", "ack", "hub", "tig", "heroku", | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | macvim_install = ("macvim --override-system-vim --custom-system-icons " | 
					
						
							|  |  |  |                   "--with-features=huge --enable-rubyinterp " | 
					
						
							|  |  |  |                   "--enable-pythoninterp --enable-perlinterp --enable-cscope") | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | MISC = ("file-formula", "less", "openssh --with-brewed-openssl", | 
					
						
							| 
									
										
										
										
											2014-10-16 17:01:43 -07:00
										 |  |  |         "perl518", "rsync", "svn", "unzip", "docker", "boot2docker", "pandoc", | 
					
						
							| 
									
										
										
										
											2014-10-28 14:09:59 -07:00
										 |  |  |         "mercurial", "ctags-exuberant",  macvim_install) | 
					
						
							| 
									
										
										
										
											2014-10-28 15:43:47 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | CASKS = ( | 
					
						
							|  |  |  |     'caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'synergy', | 
					
						
							|  |  |  |     'virtualbox', 'xquartz', 'slate', 'java', 'vlc', 'seil', 'karabiner', | 
					
						
							|  |  |  |     'mactex' | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-10 00:13:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | @ctask | 
					
						
							|  |  |  | def osx_config(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     ctx.run('sudo {0}'.format( | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  |         os.path.join(util.RESOURCES_DIRECTORY, 'osx.sh') | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  |     ), pty=True) | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-10 00:13:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-31 17:07:28 -07:00
										 |  |  | @ctask | 
					
						
							|  |  |  | def cider_install(ctx): | 
					
						
							| 
									
										
										
										
											2014-11-10 00:13:30 -08:00
										 |  |  |     ctx.run('brew install caskroom/cask/brew-cask') | 
					
						
							| 
									
										
										
										
											2014-10-31 18:34:49 -07:00
										 |  |  |     if not util.command_exists('cider'): | 
					
						
							|  |  |  |         ctx.run('sudo pip install cider') | 
					
						
							|  |  |  |     ctx.run('cider restore') | 
					
						
							| 
									
										
										
										
											2014-10-31 17:07:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | @ctask | 
					
						
							|  |  |  | def brew_cask(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-28 14:09:59 -07:00
										 |  |  |     ctx.run('brew update') | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  |     ctx.run('brew install caskroom/cask/brew-cask') | 
					
						
							|  |  |  |     for cask in CASKS: | 
					
						
							|  |  |  |         ctx.run('brew cask install {0}'.format(cask)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | @ctask | 
					
						
							|  |  |  | def get_brew(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  |     if not util.command_exists('brew'): | 
					
						
							| 
									
										
										
										
											2014-10-26 23:32:35 -07:00
										 |  |  |         ctx.run('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"') | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-10 00:13:30 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | @ctask | 
					
						
							|  |  |  | def brew_install(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-28 14:09:59 -07:00
										 |  |  |     ctx.run('brew update') | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  |     for package_name in ESSENTIAL + BASICS + SHOULD_INSTALL + MISC: | 
					
						
							|  |  |  |         ctx.run('brew install {0}'.format(package_name)) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-20 20:15:11 -07:00
										 |  |  | @ctask | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  | def setup_cocoa_emacs(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-21 15:20:43 -07:00
										 |  |  |     if not os.path.exists('/Applications/Emacs.app'): | 
					
						
							|  |  |  |         ctx.run('ln -s $(brew --prefix emacs)/Emacs.app /Applications/Emacs.app', hide=True) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-21 11:00:04 -07:00
										 |  |  |     launch_agent_dir = os.path.expanduser('~/Library/LaunchAgents/') | 
					
						
							|  |  |  |     filename = 'set-path.plist' | 
					
						
							| 
									
										
										
										
											2014-10-21 15:20:43 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     source = os.path.join(util.RESOURCES_DIRECTORY, filename) | 
					
						
							|  |  |  |     destination = os.path.join(launch_agent_dir, filename) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if os.path.exists(source) and not os.path.exists(destination): | 
					
						
							|  |  |  |         util.ensure_path_exists(launch_agent_dir) | 
					
						
							|  |  |  |         ctx.run('ln -s {0} {1}'.format(source, destination)) | 
					
						
							| 
									
										
										
										
											2014-10-20 20:15:11 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-23 02:38:27 -07:00
										 |  |  | APPS_NEEDING_ASSISTIVE_DEVICE_ACCESS = ('Slate', 'Synergy', 'iTerm') | 
					
						
							|  |  |  | @ctask | 
					
						
							| 
									
										
										
										
											2014-10-23 15:42:28 -07:00
										 |  |  | def enable_access_for_assistive_devices(ctx): | 
					
						
							| 
									
										
										
										
											2014-10-23 02:38:27 -07:00
										 |  |  |     for app in APPS_NEEDING_ASSISTIVE_DEVICE_ACCESS: | 
					
						
							|  |  |  |         app_string = '/Applications/{0}.app'.format(app) | 
					
						
							|  |  |  |         user_application = os.path.expanduser('~' + app_string) | 
					
						
							| 
									
										
										
										
											2014-10-24 06:19:23 -07:00
										 |  |  |         enable_access_if_exists(ctx, user_application) | 
					
						
							|  |  |  |         enable_access_if_exists(ctx, app_string) | 
					
						
							| 
									
										
										
										
											2014-10-25 17:51:05 -07:00
										 |  |  |         enable_access_if_exists( | 
					
						
							|  |  |  |             ctx, | 
					
						
							|  |  |  |             "/Applications/Karabiner.app/Contents/Applications/Karabiner_AXNotifier.app" | 
					
						
							|  |  |  |         ) | 
					
						
							| 
									
										
										
										
											2014-10-24 06:19:23 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | def enable_access_if_exists(ctx, app_string): | 
					
						
							|  |  |  |     if os.path.exists(app_string): | 
					
						
							|  |  |  |         ctx.run( | 
					
						
							|  |  |  |             'zsh -c "source ~/.zshrc && ' | 
					
						
							|  |  |  |             'enable_access_for_assistive_devices \"{0}\""'.format( | 
					
						
							|  |  |  |                 app_string | 
					
						
							| 
									
										
										
										
											2014-10-23 02:38:27 -07:00
										 |  |  |             ) | 
					
						
							| 
									
										
										
										
											2014-10-24 06:19:23 -07:00
										 |  |  |         ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @ctask | 
					
						
							|  |  |  | def enable_hyper(ctx): | 
					
						
							|  |  |  |     source = '{0}/karabiner-hyper.xml'.format(util.RESOURCES_DIRECTORY) | 
					
						
							|  |  |  |     destination = os.path.expanduser("~/Library/Application\\ Support/Karabiner/private.xml") | 
					
						
							|  |  |  |     try: | 
					
						
							|  |  |  |         ctx.run("rm {0}".format(destination)) | 
					
						
							|  |  |  |     except: | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  |     ctx.run("ln -s {0} {1}".format(source, destination)) | 
					
						
							|  |  |  |     ctx.run("{0}/karabiner_config.sh".format(util.RESOURCES_DIRECTORY)) | 
					
						
							| 
									
										
										
										
											2014-10-23 02:38:27 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-10 04:00:19 -07:00
										 |  |  | @ctask | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  | def enable_locate(ctx): | 
					
						
							|  |  |  |     ctx.run('sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-28 14:09:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-09 22:18:16 -08:00
										 |  |  | @ctask | 
					
						
							|  |  |  | def install_rvm(ctx): | 
					
						
							|  |  |  |     ctx.run('\curl -sSL https://get.rvm.io | bash -s stable') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-10-28 14:09:59 -07:00
										 |  |  | @ctask | 
					
						
							| 
									
										
										
										
											2014-11-10 02:00:46 -08:00
										 |  |  | def install_powerline_monaco(ctx): | 
					
						
							|  |  |  |     ctx.run('open {0}'.format(os.path.join(util.RESOURCES_DIRECTORY, "Monaco-Powerline.otf"))) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @ctask | 
					
						
							|  |  |  | def get_command_line_tools(ctx): | 
					
						
							|  |  |  |     if not util.command_exists('gcc'): | 
					
						
							|  |  |  |         ctx.run('xcode-select --install') |