def tmux_install(): if yesno('own_tmux', 'Compile tmux from source?', None): need_installpkg( apt=('libevent-dev', 'ncurses-dev'), brew=('automake', 'libevent'), ) tmux = InstallFromSource('https://github.com/tmux/tmux.git', '~/src/tmux.git') tmux.select_tag('2.7') tmux.compile_cmd([ # distclean will always fail if there's nothing to clean ['bash', '-c', 'make distclean || :'], ['sh', 'autogen.sh'], ['./configure'], ['make'], ]) tmux.symlink('tmux', '~/bin/tmux') tmux.symlink('tmux.1', '~/man/man1/tmux.1') run(tmux) else: try: # install tmux using brew or apt-get ... installpkg('tmux') except Exception: print("-" * 50) print( "Compiling `tmux` failed - do you need to install automake or gcc?" ) # noqa print("-" * 50) raise
def zsh_config(): lineinfile('~/.zshrc', 'source $HOME/.shellrc', where=WHERE_TOP) install_completions('~/.zshrc') lineinfile('~/.zshrc', 'shell_init_done # this line must be last', where=WHERE_END) antigen = InstallFromSource('https://github.com/zsh-users/antigen.git', '~/src/antigen.git') antigen.select_tag('v2.2.3') run(antigen)
def fzf_install(): if not yesno('install_fzf', 'Install fzf?', want_full): return if haveexecutable('brew') and allow_installing_stuff: installpkg('fzf') brewpath = execute(['brew', '--prefix'], stdout=True)[1].decode('utf-8').strip() if brewpath == '/opt/homebrew': # brew puts the fzf files into versioned folders, so all we can do # is glob and sort (which isn't perfect because it would need to be # a semver-compatible sort) and pick the first one fzf_path = execute( [ 'bash', '-c', f'echo {brewpath}/Cellar/fzf/* | sort -r | head -n 1' ], stdout=True, )[1].decode('utf-8').strip() else: # this is how it was on my old mac fzf_path = brewpath + '/opt/fzf' else: # do it the long way import os.path fzf_repo = os.path.expanduser('~/src/fzf.git') fzf_install = InstallFromSource('https://github.com/junegunn/fzf.git', fzf_repo) fzf_install.select_tag('0.17.3') fzf_install.compile_cmd([ ['./install', '--bin'], ]) fzf_install.symlink('bin/fzf', '~/bin/fzf') run(fzf_install) execute(['./install', '--bin'], cwd=fzf_repo, stdout='TTY') fzf_path = fzf_repo lineinfile('~/.bashrc', 'source {}/shell/completion.bash'.format(fzf_path)) lineinfile('~/.bashrc', 'source {}/shell/key-bindings.bash'.format(fzf_path)) if wantzsh(): lineinfile('~/.zshrc', 'source {}/shell/completion.zsh'.format(fzf_path)) lineinfile('~/.zshrc', 'source {}/shell/key-bindings.zsh'.format(fzf_path))
def nvim_install(): if install_nvim_via_apt(): installpkg('neovim') installpkg('python-neovim') return if (allow_installing_stuff and haveexecutable('brew') and yesno('install_nvim_package', 'Install nvim from apt/brew?')): installpkg('neovim') return the_hard_way = yesno('compile_nvim', 'Compile/install nvim from source?', recommended=allow_installing_stuff) if not the_hard_way: raise Exception('No way to install neovim') need_installpkg( apt=( 'libtool', 'libtool-bin', 'autoconf', 'automake', 'cmake', 'g++', 'pkg-config', 'unzip', 'gettext', ), yum=('cmake', 'gcc-c++', 'unzip'), brew=('cmake', 'libtool', 'gettext'), ) n = InstallFromSource('https://github.com/neovim/neovim.git', '~/src/neovim.git') n.select_tag(NVIM_TAG) n.compile_cmd([ ['make', 'distclean'], ['make'], ['sudo', 'make', 'install'], ]) run(n)
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)