Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 89 lines (67 sloc) 2.21 KB
#!/usr/bin/env python
# encoding: utf-8
from os import environ, listdir
from os.path import dirname, exists, expanduser, join, realpath
from subprocess import call
import sys
from time import sleep
def ask_yn(question):
question += ' (y/n) '
answer = None
while answer not in ['yes', 'y', 'no', 'n']:
answer = raw_input(question).lower()
return answer.startswith('y')
def brew():
# get installed apps
cellar_dir = '/usr/local/Cellar'
installed = listdir(cellar_dir) if exists(cellar_dir) else []
# get desired apps
with open(expanduser('~/.brew')) as f:
desired = map(str.strip, f.readlines())
# install missing apps
for app in sorted(set(desired) - set(installed)):
print app
run('brew install ' + app)
print
def run(command):
return call(command, shell=True)
def _main():
# get dotfiles directory
dotfiles_dir = dirname(realpath(__file__))
# run installer
installer_path = join(dotfiles_dir, 'installer/installer.py')
run('python ' + installer_path)
# "install" git submodules
print '\n\n"installing" git submodules...'
sys.stdout.flush()
sleep(2)
run(' && '.join(['cd ' + dotfiles_dir,
'git submodule init',
'git submodule update']))
# install homebrew stuff
print '\n'
if ask_yn('install homebrew stuff?'):
brew()
# create tags for vim documentation
print '\n\ncreating tags for vim documentation...',
sys.stdout.flush()
sleep(2)
run('mvim -c "Helptags | quit"; sleep 1; open -a iterm')
print 'done'
# source ~/.osx
cmd = 'source ~/.osx'
print '\n'
if ask_yn(cmd + '?'):
run(cmd)
# show tips
print '\n\ntips:'
print ' - comment out /etc/zshenv contents to get correct $PATH in MacVim'
print ' - modify home/.gitfiles/template/hooks -- it\'s an absolute'
print ' symlink to /Users/narf/.gitfiles/hooks (sorry)'
# tell how to switch to zsh
shell = environ.get('SHELL')
if not shell or not shell.endswith('zsh'):
print ' - run "chsh -s `which zsh` $USER" to switch to zsh ' \
'(you may need to relog)'
if __name__ == '__main__':
_main()
Something went wrong with that request. Please try again.