def copy_default_ssh_folder(source_dir, _target): print_title('SSH config') _from = concat_path_and_normalize( source_dir, 'ssh/default-config' ) shutil.copy(_from, _target)
def create_code_dir(force=False): print_title('Code directory') k = os.path.join(str(Path.home()), 'code') if os.path.exists(k): ok_indent('Code already created!') else: os.mkdir(k) ok_indent('Created code directory')
def ssh(): if not is_windows(): return print_title('SSH') ssh_agent_running = os.environ.get('SSH_AUTH_SOCK') or False if ssh_agent_running: ok_indent('SSH-Agent is running.') else: failure_indent('SSH-Agent is not running.') os.path.exists('.ssh') read_ssh_keys()
def install_xdg_config_home(force=False): print_title('Dot files') files = [ 'zsh', 'vim', 'git' ] for file in files: symlink_file( os.path.join(SOURCE_DIR, file), os.path.join(xdg.config, file) )
def ssh(force=False): if not is_windows(): return print_title('SSH') ssh_agent_running = os.environ.get('SSH_AUTH_SOCK') or False if ssh_agent_running: ok_indent('SSH-Agent is running.') else: failure_indent('SSH-Agent is not running.') os.path.exists('.ssh') read_ssh_keys()
def install_bash(force=False): print_title('Bash') if not ask('Do you want install bash configs?'): return paths = [ ('bash/bashrc', '.bashrc'), ('bash/bash_profile', '.bash_profile'), ] for s, t in paths: copy_file( concat_path_and_normalize(SOURCE_DIR, s), concat_path_and_normalize(INSTALL_TARGET, t) )
def install_utils(force=False): print_title('CLI Utilities') file_path = concat_path_and_normalize(SOURCE_DIR, 'dotbin/z.sh') if not os.path.exists(file_path) and ask('Install Z auto jump'): url = 'https://raw.githubusercontent.com/rupa/z/master/z.sh' urllib.request.urlretrieve(url, file_path) os.chmod(file_path, 0o744) ok_indent('Z installed') else: ok_indent('Z already installed') pass
def local_files(): print_title('Local files') files = [ (xdg.config, 'vim/vimrc.local'), (xdg.config, 'zsh/.zshrc.local'), ] for parent, _file in files: p = concat_path_and_normalize(parent, _file) if not os.path.exists(p): with open(p, 'w'): pass ok_indent(f'Local file {p} created') else: ok_indent(f'Local file {p} already created!')
def install_vim_plug(force=False): print_title('Vim-Plug') vim_plug_path = concat_path_and_normalize( xdg.cache, 'vim/autoload/plug.vim' ) if os.path.exists(vim_plug_path): ok_indent('Vim-Plug already installed!') return vim_plug_addr = 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' parent_folder = ntpath.dirname(vim_plug_path) if not os.path.exists(parent_folder): os.makedirs(parent_folder) urllib.request.urlretrieve(vim_plug_addr, vim_plug_path) ok_indent('Vim-Plug installed!')
def install_vscode(force=False): print_title('Visual Studio Code Settings') if not is_mac(): prefix = '~/.config' else: prefix = '~/Library/Application\ Support' if check_if_already_configured(concat_path_and_normalize(prefix, 'Code/User/settings.json')): ok_indent('Visual Studio Code Settings already installed!') return if not ask('Install Visual Studio Code Settings'): return symlink_file( concat_path_and_normalize(SOURCE_DIR, 'vscode/settings.json'), concat_path_and_normalize(prefix, 'Code/User/settings.json'), )
def install_git(force=False): print_title('Git') local_git_config = concat_path_and_normalize(xdg.config, 'git/config.local') installed = False if os.path.exists(local_git_config): installed = True email, user_name = read_local_git_config(local_git_config) present_git_config(email, user_name) prefix = 're' if installed else '' if force or ask(f'Do you want to {prefix}configure git?'): newline() full_name = input(indent('* What\'s your full name? ')) email = input(indent('* What\'s your e-mail address? ')) newline() write_local_git_config(local_git_config, full_name, email) newline() ok_indent('Git config installed')
def link_zsh(source_dir): print_title('Zsh') target = concat_path_and_normalize( str(Path.home()), '.zshenv' ) source = concat_path_and_normalize( source_dir, 'zsh/.zshenv' ) if os.path.exists(target) or os.path.islink(target): ok_indent('.zshenv already installed!') return if not ask('Do you want to install .zshenv?'): return if is_windows(): shutil.copy(source, target) ok_indent('Copied .zshenv') else: os.symlink(source, target) ok_indent('Linked .zshenv')
def install_xdg_defaults(force=False): print_title('XDG Defaults') for x, y in vars(xdg).items(): if not os.path.exists(y): os.makedirs(y) ok_indent(f'XDG {x} folder created ({y})')