def legacypl(): if yesno('install_legacypl', 'Create clone of legacy-pl?', want_full): mkdir('~/playground-6') legacy = InstallFromSource('ssh://[email protected]/phodge/legacy-pl.git', '~/playground-6/legacy-pl.git') legacy.select_branch('develop') run(legacy)
def envup_install(): pipinstall('libtmux', trypips=['pip3']) symlink('bin/envup', '~/bin/envup') mkdir('~/.envup') symlink('envup/loki.json', '~/.envup/loki.json') symlink('envup/p90-bg.json', '~/.envup/p90-bg.json') symlink('envup/p90-code.json', '~/.envup/p90-code.json') symlink('envup/p90-resume.json', '~/.envup/p90-resume.json') symlink('envup/p90-resume-bg.json', '~/.envup/p90-resume-bg.json')
def jerjerrod_addline(command, path, ignore=[]): # track projects in ~/src mkdir('~/.config') mkdir('~/.config/jerjerrod') # some sensible defaults for how I like to do things assert command in ("PROJECT", "WORKSPACE", "FORGET") flags = [] flags += ["IGNORE={}".format(p) for p in ignore] lineinfile('~/.config/jerjerrod/jerjerrod.conf', "{} {} {}".format(command, path, " ".join(flags)).rstrip())
def git_completion(): # TODO: would be good to use git submodules for these so we get pinned/stable versions # install completion utilities for bash url = 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash' download(url, '~/src/git-completion.bash') lineinfile('~/.bashrc', 'source $HOME/src/git-completion.bash', where=WHERE_END) # install completion utilities for zsh url = 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.zsh' mkdir('~/.zsh') download(url, '~/.zsh/_git')
def tools(): if yesno('install_with', 'Install `with` utility?', want_full): withutil = InstallFromSource('https://github.com/mchav/with', '~/src/with.git') withutil.symlink('with', '~/bin/with') withutil.select_branch('master') run(withutil) if yesno('install_universal_ctags', 'Install Universal Ctags?', want_full): need_installpkg(apt=('autoconf', 'g++')) mkdir('~/bin') if haveexecutable('brew'): # install with homebrew execute(['brew', 'tap', 'universal-ctags/universal-ctags']) execute(['brew', 'install', '--HEAD', 'universal-ctags']) else: uc = InstallFromSource('https://github.com/universal-ctags/ctags', '~/src/universal-ctags.git') uc.select_branch('master') uc.compile_cmd([ ['./autogen.sh'], ['./configure'], ['make'], ]) uc.symlink('ctags', '~/bin/ctags') run(uc) elif allow_installing_stuff and yesno('install_ctags', 'Install `ctags`?', want_full): installpkg('ctags') if allow_installing_stuff and yesno('install_patch', 'Install patch?', want_full): installpkg('patch') if allow_installing_stuff and yesno('install_tidy', 'Install tidy cli tool?', want_full): installpkg('tidy') # on OSX we want to install gnu utils (brew install coreutils findutils) # and put /usr/local/opt/coreutils/libexec/gnubin in PATH if IS_OSX and haveexecutable('brew') and allow_installing_stuff: if yesno('brew_install_coreutils', 'Install gnu utils?', default=want_full): brew_list = set( execute(['brew', 'list'], stdout=True)[1].decode('utf-8').splitlines()) install = [ pkg for pkg in ('coreutils', 'findutils') if pkg not in brew_list ] if len(install): execute(['brew', 'install'] + install)
def neovim_python_devel(): playground = 'playground-neovim-python' venv = HOME + '/' + playground msg = 'Put a dev version of neovim-python in %s?' % playground if not yesno('install_neovim_python', msg, False): return # my fork of the neovim project origin = 'ssh://[email protected]/phodge/python-client.git' # the main neovim repo - for pulling neovim = 'https://github.com/neovim/python-client.git' # where to put the local clone checkout = venv + '/python-client.git' # create the symlink for the neovim project mkdir(venv) if not os.path.exists(checkout): # NOTE: using execute() directly means the checkout directory isn't tracked by homely ... # this is exactly what I want execute(['git', 'clone', origin, checkout]) execute(['git', 'remote', 'add', 'neovim', neovim], cwd=checkout) execute(['git', 'fetch', 'neovim', '--prune'], cwd=checkout) if not os.path.exists(os.path.join(venv, 'bin')): execute(['virtualenv', '--python=python3', venv], stdout="TTY") if not os.path.exists(os.path.join(venv, 'bin')): execute(['virtualenv', '--python=python3', venv], stdout="TTY") # create a python2 virtualenv as well py2venv = os.path.join(venv, 'py2venv') if not os.path.exists(os.path.join(py2venv, 'bin')): execute(['virtualenv', '--python=python2.7', py2venv], stdout="TTY") # create a symlink to the git repo symlink(checkout, os.path.join(py2venv, 'python-client.git')) for path in [venv, py2venv]: pip = os.path.join(path, 'bin', 'pip') execute([pip, 'install', '--editable', 'python-client.git'], cwd=path) mypips(pip) # we will definitely need tests execute([pip, 'install', 'nose']) if wantjerjerrod(): # register the playground with jerjerrod jerjerrod_addline('WORKSPACE', venv, ignore=["py2venv"])
def init_composer(): global INIT_DONE if not haveexecutable('composer'): raise Exception("TODO: composer is not installed") # noqa composer_config = { 'minimum-stability': 'dev', 'prefer-stable': True, } mkdir('~/.config') mkdir('~/.config/composer') with writefile('~/.config/composer/composer.json') as f: json.dump(composer_config, f) INIT_DONE = True
def nvim_devel(): # my fork of the neovim project origin = 'ssh://[email protected]/phodge/neovim.git' # the main neovim repo - for pulling neovim = 'https://github.com/neovim/neovim.git' # where to put the local clone dest = HOME + '/playground-6/neovim' if not os.path.exists(dest): # NOTE: using execute() directly means the dest directory isn't tracked by # homely ... this is exactly what I want execute(['git', 'clone', origin, dest]) execute(['git', 'remote', 'add', 'neovim', neovim], cwd=dest) execute(['git', 'fetch', 'neovim', '--prune'], cwd=dest) # create the symlink for the neovim project mkdir('~/playground-6') symlink(HERE + '/vimproject/neovim', dest + '/.vimproject')
def mkdir_r(path): assert len(path) if os.path.islink(path): raise Exception( "Cannot mkdir_r(%r): path already exists but is a symlink" % path) # if the thing already exists but isn't a dir, then we can't create it if os.path.exists(path) and not os.path.isdir(path): raise Exception( "Cannot mkdir_r(%r): path already exists but is not a dir" % path) # create the parent then our target path parent = os.path.dirname(path) if len(parent) > 5: mkdir_r(parent) mkdir(path)
def homely_dev(): if not yesno("create_homely_venv", "Create ~/playground-homely virtualenv?", False): return venv = environ['HOME'] + '/playground-homely' # create container dir mkdir(venv) checkout = join(venv, 'homely.git') # create the virtualenv if it doesn't already exist if not exists(join(venv, 'bin')): execute(['virtualenv', '--python=python3', venv], stdout="TTY") # check out homely.git repo if it isn't there yet if not exists(checkout): execute(['git', 'clone', '[email protected]:phodge/homely.git', checkout], stdout="TTY") # need to install editable version of homely.git in both virtualenvs venv_pip = venv + '/bin/pip' execute([venv_pip, 'install', '--editable', checkout]) mypips(venv_pip) # install all dev requirements execute( [venv_pip, 'install', '-r', join(checkout, 'requirements_dev.txt')]) if wantjerjerrod(): # register the playground with jerjerrod jerjerrod_addline('WORKSPACE', venv, ignore=["py2venv"]) # we may want to install pandoc to make the slides, but if yesno('homley_want_pandoc', 'Install pandoc to create slides?', recommended=True): from homely.install import installpkg installpkg('pandoc')
def tmux_config(): tmux_plugins = yesno('install_tmux_plugins', 'Install TPM and use tmux plugins?', want_full) if tmux_plugins: mkdir('~/.tmux') mkdir('~/.tmux/plugins') tpm = InstallFromSource('https://github.com/tmux-plugins/tpm', '~/.tmux/plugins/tpm') tpm.select_branch('master') run(tpm) # what to put in tmux config? wildcards = {"DOTFILES": HERE, "HOME": HOME} lines = ['source ~/.tmux/keybindings.conf'] # add our dotfiles python folder to PYTHONPATH before restarting the powerline daemon #lines.append("set-environment PYTHONPATH '%(DOTFILES)s/python'") if tmux_plugins: lines.append('source "%(DOTFILES)s/tmux/plugins.conf"') # FIXME: the only way to determine if TPM installed correctly is to # press `[PREFIX]`, `I` to do a plugin install lines.append('source "%(DOTFILES)s/tmux/tmux.conf"') if wantpowerline(): wildcards["POWERLINE"] = powerline_path() lines.extend([ # always replace the daemon on startup, so that re-sourcing the # tmux conf always loads updated python modules 'source "%(POWERLINE)s/bindings/tmux/powerline.conf"', 'run-shell "powerline-daemon --replace -q"', ]) lines = [l % wildcards for l in lines] # noqa: E741 blockinfile('~/.tmux.conf', lines, '# start of automated tmux config', '# end of automated tmux config', where=WHERE_TOP)
def mypips(venv_pip=None, write_dev_reqs=False): # if we're on macos then we need to tell homely.pipinstall to use 'pip3' instead of 'pip' if IS_OSX: pips = ['pip3'] else: pips = None # of course we probably want virtualenv! if venv_pip is None: pipinstall('virtualenv', pips=pips) theworks = want_full or venv_pip # these packages will be installed using the virtualenv's pip, or pip2+pip3 depending on what's # present. They're needed for development. packages = [ 'jedi', 'yapf', 'isort', # needed for `git rebase -i` commit comparisons 'GitPython', ] if wantnvim() and not install_nvim_via_apt(): # if we want nvim then we probably need the pynvim package packages.append('pynvim') # a nice python repl if theworks or yesno('install_ptpython', 'PIP Install ptpython?', True): packages.append('ptpython') # another nice python repl if theworks or yesno('install_ipython', 'PIP Install iPython?', True): packages.append('ipython') # a few of my macros use `q` for logging if theworks or yesno('install_python_q', 'PIP Install `q`?', True): packages.append('q') if write_dev_reqs: assert venv_pip is None mkdir('~/.config') with writefile('~/.config/dev_requirements.txt') as f: f.write('flake8\n') for p in packages: f.write(p + '\n') if want_python2_anything: trypips = ['pip2', 'pip3'] else: trypips = ['pip3'] for package in packages: if venv_pip: venv_exec(venv_pip, ['pip', 'install', package]) else: mypipinstall(package, trypips=trypips) # if it's a virtualenv, always just install flake8. Otherwise, we need to ask the user if # they want to install both if venv_pip: venv_exec(venv_pip, ['pip', 'install', 'flake8']) else: # always install simplejson globally as we need it for other parts of our homely install mypipinstall('simplejson', trypips=trypips) have_pip3 = haveexecutable('pip3') if have_pip3 and yesno('install_flake8_python3', 'Install flake8 for python3?'): mypipinstall('flake8', ['pip3']) if want_python2_anything and yesno('install_flake8_python2', 'Install flake8 for python2?'): mypipinstall('flake8', ['pip2'])
def powerline(): mypipinstall('powerline-status', ['pip3']) mkdir('~/.config') mkdir('~/.config/powerline') paths = [ "%s/config_files" % powerline_path(), "%s/powerline" % HERE, "%s/.config/powerline" % HOME, ] if allow_installing_stuff and IS_UBUNTU: msg = 'Install fonts-powerline package for this OS? (Works on Ubuntu)' if yesno('powerline_fonts', msg, False, noprompt=False): execute(['sudo', 'apt-get', 'install', 'fonts-powerline'], stdout="TTY") lines = [ 'export POWERLINE_CONFIG_PATHS=%s' % ":".join(paths), ] if want_unicode_fix(): lines.append('export HOMELY_POWERLINE_HOUSE=H') blockinfile('~/.shellrc', lines, WHERE_END) # ask the user what colour prefs they would like and put it in # ~/.config/powerline/colors.sh colourfile = os.path.join(HOME, '.config', 'powerline', 'colours.sh') load = False defaults = dict( bg="gray1", fg1="white", fg2="gray6", ) if not os.path.exists(colourfile): if yesno(None, 'Select base colours now?', True, noprompt=False): # load available colours from colors.json with open("%s/config_files/colors.json" % powerline_path()) as f: import simplejson colors = simplejson.load(f) with open(colourfile, 'w') as f: f.write( "# Set the 3 variables using colour names from below.\n") f.write( "# WARNING! If you misspell a colour your powerline may not work!\n" ) f.write("#\n") f.write("# primary background colour\n") f.write("bg=%(bg)s\n" % defaults) f.write("# foreground colour for highlighted tab\n") f.write("fg1=%(fg1)s\n" % defaults) f.write("# foreground colour for other tabs\n") f.write("fg2=%(fg2)s\n" % defaults) f.write("# possible colours:\n") for name in sorted(colors.get("colors", {})): f.write("# %s\n" % name) execute(['vim', colourfile], stdout="TTY") load = True else: load = True if yesno(None, 'Select base colours now?', False, noprompt=False): execute(['vim', colourfile], stdout="TTY") colourset = defaults if load: with open(colourfile, 'r') as f: for line in [l.rstrip() for l in f]: # noqa: E741 if len(line) and not line.startswith('#'): import pprint print('line = ' + pprint.pformat(line)) # noqa TODO name, val = line.split('=') colourset[name] = val data = {} data["groups"] = { "window:current": { "bg": colourset["bg"], "fg": colourset["fg1"], "attrs": [] }, "window_name": { "bg": colourset["bg"], "fg": colourset["fg1"], "attrs": ["bold"] }, # noqa "session:prefix": { "bg": colourset["bg"], "fg": "gray90", "attrs": ["bold"] }, "active_window_status": { "fg": colourset["fg2"], "bg": "gray0", "attrs": [] }, "hostname": { "bg": colourset["bg"], "fg": "gray90", "attrs": [] }, } # write out a colorscheme override for tmux using our powerline colours mkdir('~/.config') mkdir('~/.config/powerline') mkdir('~/.config/powerline/colorschemes') mkdir('~/.config/powerline/colorschemes/tmux') import simplejson dumped = simplejson.dumps(data) with writefile('~/.config/powerline/colorschemes/tmux/default.json') as f: f.write(dumped)
def vim_config(): # install vim-plug into ~/.vim mkdir('~/.vim') mkdir('~/.nvim') mkdir('~/.config') mkdir('~/.config/nvim') symlink('~/.vimrc', '~/.config/nvim/init.vim') mkdir('~/.vim/autoload') download( 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', '~/.vim/autoload/plug.vim') def mkdir_r(path): assert len(path) if os.path.islink(path): raise Exception( "Cannot mkdir_r(%r): path already exists but is a symlink" % path) # if the thing already exists but isn't a dir, then we can't create it if os.path.exists(path) and not os.path.isdir(path): raise Exception( "Cannot mkdir_r(%r): path already exists but is not a dir" % path) # create the parent then our target path parent = os.path.dirname(path) if len(parent) > 5: mkdir_r(parent) mkdir(path) def _static(url, dest): dest = HOME + '/.vimstatic/' + dest mkdir_r(os.path.dirname(dest)) download(url, dest) vprefs = HOME + '/.vim/prefs.vim' nprefs = HOME + '/.nvim/prefs.vim' # chuck in a reference to our shiny new vimrc.vim (this will end up below the rtp magic block) lineinfile('~/.vimrc', 'source %s/vimrc.vim' % HERE, where=WHERE_TOP) # do we want a debugger plugin in vim? for varname, varval in get_vim_options().items(): lineinfile( '~/.vim/prefs.vim', f'let {varname} = {"1" if varval else "0"} " set by phodge\'s dotfiles' .format(varname, '1' if varval else '0'), where=WHERE_END, ) # put our magic &rtp block at the top of our vimrc blockinfile('~/.vimrc', [ ' " reset rtp', ' set runtimepath&', ' " let other scripts know they\'re allowed to modify &rtp', ' let g:allow_rtp_modify = 1', ' " grab local preferences', ' if filereadable(%r)' % vprefs, ' source %s' % vprefs, ' endif', ' if has(\'nvim\') && filereadable(%r)' % nprefs, ' source %s' % nprefs, ' endif', ], '" {{{ START OF dotfiles runtimepath magic', '" }}} END OF dotfiles runtimepath magic', where=WHERE_TOP) # if the .vimrc.preferences file doesn't exist, create it now if not os.path.exists(vprefs): with open(vprefs, 'w') as f: f.write('let g:vim_peter = 1\n') # make sure we've made a choice about clipboard option in vprefs file @whenmissing(vprefs, 'clipboard') def addclipboard(): if allowinteractive(): if yesno(None, 'Use system clipboard in vim? (clipboard=unnamed)', None): rem = "Use system clipboard" val = 'unnamed' else: rem = "Don't try and use system clipboard" val = '' with open(vprefs, 'a') as f: f.write('" %s\n' % rem) f.write("set clipboard=%s\n" % val) # put a default value about whether we want the hacky mappings for when the # terminal type isn't set correctly @whenmissing(vprefs, 'g:hackymappings') def sethackymappings(): with open(vprefs, 'a') as f: f.write('" Use hacky mappings for F-keys and keypad?\n') f.write('let g:hackymappings = 0\n') # in most cases we don't want insight_php_tests @whenmissing(vprefs, 'g:insight_php_tests') def setinsightphptests(): with open(vprefs, 'a') as f: f.write('" Do we want to use insight to check PHP code?\n') f.write('let g:insight_php_tests = []\n') # lock down &runtimepath lineinfile('~/.vimrc', 'let g:allow_rtp_modify = 0', where=WHERE_END) # if we have jerjerrod installed, add an ALWAYSFLAG entry for git repos in ~/src/plugedit if False and wantjerjerrod(): mkdir('~/.config') mkdir('~/.config/jerjerrod') lineinfile('~/.config/jerjerrod/jerjerrod.conf', 'PROJECT ~/src/plugedit/*.git ALWAYSFLAG') # icinga syntax/filetype if yesno('want_vim_icinga_stuff', 'Install vim icinga2 syntax/ftplugin?', default=False): files = ['syntax/icinga2.vim', 'ftdetect/icinga2.vim'] for name in files: url = 'https://raw.githubusercontent.com/Icinga/icinga2/master/tools/syntax/vim/{}' _static(url.format(name), name) # <est> utility hasphp = haveexecutable('php') if yesno('install_est_utility', 'Install <vim-est>?', hasphp): est = InstallFromSource('https://github.com/phodge/vim-est.git', '~/src/vim-est.git') est.select_branch('master') est.symlink('bin/est', '~/bin/est') run(est)
def powerline_theme(): right = [ { "function": "todonext.powerline.firstitem" }, ] if haveexecutable('jerjerrod') and wantjerjerrod(): wsnames = "jerjerrod.powerline.wsnames" right += [ { "function": "jerjerrod.powerline.wsscancount" }, { "function": wsnames, "args": { "category": "JERJERROD:CHANGED" } }, { "function": wsnames, "args": { "category": "JERJERROD:UNTRACKED" } }, { "function": wsnames, "args": { "category": "JERJERROD:UNPUSHED" } }, { "function": wsnames, "args": { "category": "JERJERROD:UNKNOWN" } }, ] right.append({ "function": "homely.powerline.shortstatus", "args": { "autoupdate": True, "reattach_to_user_namespace": haveexecutable('reattach-to-user-namespace'), "colors": { "paused": "HOMELY:PAUSED", "running": "HOMELY:RUNNING", "failed": "HOMELY:FAILED", "noconn": "HOMELY:NOCONN", "dirty": "HOMELY:DIRTY", "never": "HOMELY:NEVER", "ok": "HOMELY:OK", } }, }) right.append({ "function": "powerline.segments.common.time.date", "name": "time", "args": { "format": "%H:%M", "istime": True, }, }) right.append({"function": "powerline.segments.common.net.hostname"}) config = {"segments": {"right": right}} if want_unicode_fix(): config["segment_data"] = {"time": {"before": ""}} import simplejson dumped = simplejson.dumps(config) mkdir('~/.config') mkdir('~/.config/powerline') mkdir('~/.config/powerline/themes') mkdir('~/.config/powerline/themes/tmux') with writefile('~/.config/powerline/themes/tmux/default.json') as f: f.write(dumped)
def vim_install(): # TODO: prompt to install a better version of vim? # - yum install vim-enhanced if not yesno('compile_vim', 'Compile vim from source?', want_full): return local = HOME + '/src/vim.git' mkdir('~/.config') flagsfile = HOME + '/.config/vim-configure-flags' written = False if not os.path.exists(flagsfile): written = True # pull down git source code right now so that we can see what the configure flags are if not os.path.exists(local): execute(['git', 'clone', 'https://github.com/vim/vim.git', local]) out = execute([local + '/configure', '--help'], stdout=True, cwd=local)[1] with open(flagsfile, 'w') as f: f.write('# put configure flags here\n') f.write('--with-features=huge\n') f.write('--enable-pythoninterp=yes\n') f.write('--enable-python3interp=yes\n') f.write('\n') f.write('\n') for line in out.decode('utf-8').split('\n'): f.write('# ') f.write(line) f.write('\n') if yesno(None, 'Edit %s now?' % flagsfile, written, noprompt=False): execute(['vim', flagsfile], stdout="TTY") # install required libraries first need_installpkg( apt=( 'libtool', 'libtool-bin', 'autoconf', 'automake', 'cmake', 'g++', 'pkg-config', 'unzip', 'ncurses-dev', ), brew=( 'cmake', 'libtool', ), ) inst = InstallFromSource('https://github.com/vim/vim.git', '~/src/vim.git') inst.select_tag(VIM_TAG) configure = ['./configure'] with open(flagsfile) as f: for line in f: if not line.startswith('#'): configure.append(line.rstrip()) inst.compile_cmd([ ['make', 'distclean'], configure, ['make'], ['sudo', 'make', 'install'], ]) run(inst)
def ctags(): ctagsdir = HOME + '/.ctags.d' mkdir(ctagsdir) for orig in glob.glob(HERE + '/ctags.d/*.ctags'): basename = os.path.basename(orig) symlink(orig, ctagsdir + '/' + basename)
def brew_install(): if haveexecutable('brew'): return if yesno('install_homebrew', 'Install Homebrew?', default=True): install_cmd = '/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"' execute(['bash', '-c', install_cmd], stdout="TTY") @section(quick=True) def gnuscreen(): symlink('.screenrc') # create ~/bin and ~/src if they don't exist yet mkdir('~/src') mkdir('~/bin') mkdir('~/man') mkdir('~/man/man1') # TODO: need to ensure ~/man is in our $MANPATH # TODO: need to ensure ~/bin is in our $PATH @section(quick=True) def pythonpath(): """ Add ~/dotfiles/python/ to our ~/.local/python[2/3]/site-packages dirs """ pypath = "%s/python" % HERE
def git(): hooksdir = HOME + '/.githooks' mkdir(hooksdir) # symlink our pre-commit hook into ~/.githooks symlink('git/hooks/pre-commit', '~/.githooks/pre-commit') symlink('git/hooks/applypatch-msg', '~/.githooks/applypatch-msg') symlink('git/hooks/commit-msg', '~/.githooks/commit-msg') symlink('git/hooks/fsmonitor-watchman', '~/.githooks/fsmonitor-watchman') symlink('git/hooks/p4-changelist', '~/.githooks/p4-changelist') symlink('git/hooks/p4-post-changelist', '~/.githooks/p4-post-changelist') symlink('git/hooks/p4-pre-submit', '~/.githooks/p4-pre-submit') symlink('git/hooks/p4-prepare-changelist', '~/.githooks/p4-prepare-changelist') symlink('git/hooks/post-applypatch', '~/.githooks/post-applypatch') symlink('git/hooks/post-checkout', '~/.githooks/post-checkout') symlink('git/hooks/post-commit', '~/.githooks/post-commit') symlink('git/hooks/post-index-change', '~/.githooks/post-index-change') symlink('git/hooks/post-merge', '~/.githooks/post-merge') symlink('git/hooks/post-receive', '~/.githooks/post-receive') symlink('git/hooks/post-rewrite', '~/.githooks/post-rewrite') symlink('git/hooks/post-update', '~/.githooks/post-update') symlink('git/hooks/pre-applypatch', '~/.githooks/pre-applypatch') symlink('git/hooks/pre-auto-gc', '~/.githooks/pre-auto-gc') symlink('git/hooks/pre-commit', '~/.githooks/pre-commit') symlink('git/hooks/pre-merge-commit', '~/.githooks/pre-merge-commit') symlink('git/hooks/pre-push', '~/.githooks/pre-push') symlink('git/hooks/pre-rebase', '~/.githooks/pre-rebase') symlink('git/hooks/pre-receive', '~/.githooks/pre-receive') symlink('git/hooks/prepare-commit-msg', '~/.githooks/prepare-commit-msg') symlink('git/hooks/proc-receive', '~/.githooks/proc-receive') symlink('git/hooks/push-to-checkout', '~/.githooks/push-to-checkout') symlink('git/hooks/rebase', '~/.githooks/rebase') symlink('git/hooks/reference-transaction', '~/.githooks/reference-transaction') symlink('git/hooks/sendemail-validate', '~/.githooks/sendemail-validate') symlink('git/hooks/update', '~/.githooks/update') lines = [ # include our dotfiles git config from ~/.gitconfig "[include] path = %s/git/config" % HERE, # because git config files don't support ENV vars, we need to tell it where to find our hooks "[core] hooksPath = %s/.githooks" % HOME, ] blockinfile('~/.gitconfig', lines, WHERE_TOP) # put our standard ignore stuff into ~/.gitignore with open('%s/git/ignore' % HERE, 'r') as f: lines = [l.rstrip('\r\n') for l in f.readlines()] # noqa: E741 blockinfile('~/.gitignore', lines, "# exclude items from phodge/dotfiles", "# end of items from phodge/dotfiles", where=WHERE_TOP) gitwip = InstallFromSource('https://github.com/phodge/git-wip.git', '~/src/git-wip.git') gitwip.symlink('bin/git-wip', '~/bin/git-wip') gitwip.symlink('bin/git-unwip', '~/bin/git-unwip') gitwip.select_branch('master') run(gitwip)