def install_action(self): super().install_action() # Set up local config if platform == "darwin": git_credential = "osxkeychain" elif platform == "linux": git_credential = "cache" else: git_credential = "" git_authorname = click.prompt("git author name", err=True) git_authoremail = click.prompt("git author email", err=True) with Path.home().joinpath(".gitconfig.local").open("w+") as fd: fd.write( LOCAL_CONFIG_TEMPL.format( git_authorname=git_authorname, git_authoremail=git_authoremail, git_credential=git_credential, ) ) # Create SSH key if not already present. ssh_dir = Path.home() / ".ssh" id_rsa = ssh_dir / "id_rsa" id_rsa_pub = ssh_dir / "id_rsa.pub" if not id_rsa.exists(): shell.run(f"ssh-keygen -t rsa -b 4096 -C '{git_authoremail}' -f {id_rsa}") with id_rsa_pub.open() as fd: public_key = fd.read() output.message(f"Add your public key to GitHub:\n {public_key}") shell.run(f"ssh-add -K {id_rsa}")
def _set_latest(plugin: str): """ Set the version for a plugin to the latest installed version. """ versions = _get_installed_versions(plugin) shell.run(f"asdf global {plugin} {versions[-1]}") shell.run(f"asdf reshim {plugin}")
def update(): """ Update this tool. """ root_dir = config.get_root_dir() shell.run(f"git -C {root_dir} pull") shell.run("poetry install --remove-untracked", cwd=root_dir)
def upgrade_action(self): zsh_dir = Path.home().resolve() / ".oh-my-zsh" shell.run(f"sh {zsh_dir / 'tools/upgrade.sh'}", env={"ZSH": str(zsh_dir)}) # Upgrade themes and plugins. self.ZshSyntaxHighlighting().upgrade() self.ZshAutosuggestions().upgrade()
def install_extensions(extensions: Iterable[str]): """ Install all currently uninstalled extensions. VSCode extensions cannot be upgraded from the command line so we skip already installed extensions for the sake of speed. """ for extension in set(extensions) - _get_installed_extensions(): shell.run(f"code --install-extension {extension}")
def install_action(self): shell.run( 'sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"', # noqa: E501 env={"CHSH": "no", "RUNZSH": "no", "KEEP_ZSHRC": "yes"}, ) # Install themes and plugins. self.ZshSyntaxHighlighting().install() self.ZshAutosuggestions().install()
def upgrade_action(self): if sys.platform == "darwin": # There are issues with case-insensitive filenames that prevent the repo # from being pulled on macOS. output.message( "nerd-fonts cannot be upgraded on MacOS at the moment 😞") else: super().upgrade_action() for font_name in FONTS: shell.run(f"{self.repo_path / 'install.sh'} {font_name}")
def _set_default_shell(self): zsh_path = shell.capture("which zsh") # Make sure zsh is an allowed shell. shells = Path("/etc/shells") if zsh_path not in shells.read_text(): with shells.open("a") as fd: fd.write(zsh_path + "\n") # Make zsh the default shell. shell.run(f"chsh -s {zsh_path}")
def install_or_upgrade_plugin(plugin: str): shell.run("asdf update") if plugin not in _get_installed_plugins(): shell.run(f"asdf plugin add {plugin}") else: shell.run(f"asdf plugin update {plugin}") shell.run(f"asdf install {plugin} latest") _set_latest(plugin)
def install_action(self): super().install_action() shell.run( "curl -L https://iterm2.com/shell_integration/zsh -o ~/.zshrc.d/.iterm2_shell_integration.zsh" # noqa: E501 )
def install_action(self): shell.run("sudo apt update") shell.run("sudo apt install --yes zsh") self._set_default_shell()
def install_or_upgrade_formula(formula: str): if formula.split("/")[-1] in _get_installed_formulae(): shell.run(f"brew upgrade {formula}") else: shell.run(f"brew install {formula}")
def upgrade_action(self): shell.run("poetry self update")
def install_or_upgrade_package(package: str): shell.run(f"python -m pip install --upgrade {package}")
def install_or_upgrade_cask(cask: str): if cask in _get_installed_casks(): shell.run(f"brew upgrade --cask {cask}") else: shell.run(f"brew cask install {cask}")
def install_action(self): super().install_action() shell.run("gh auth login --web")
def upgrade_action(self): shell.run(str(config.get_root_dir() / "scripts" / "set-defaults.sh"))
def install_action(self): shell.run( '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"', # noqa: E501 env={"CI": "1"}, ) shell.run("brew analytics off")
def upgrade_action(self): shell.run(f"git -C {self.repo_path} pull")
def install_or_upgrade_package(package: str): if package not in _get_installed_packages(): shell.run(f"pipx install {package}") else: shell.run(f"pipx upgrade {package}", allow_fail=True) # pipx returns 1 on success
def upgrade_action(self): super().upgrade_action() shell.run("vim +PluginInstall +qall")
def install_action(self): super().install_action() shell.run("vim +PluginInstall +qall")
def upgrade_action(self): shell.run("sudo apt update") shell.run("sudo apt upgrade --yes zsh") self._set_default_shell()
def install_action(self): output.message("... this might take a while!") super().install_action() for font_name in FONTS: shell.run(f"{self.repo_path / 'install.sh'} {font_name}")
def upgrade_action(self): shell.run("brew update") shell.run("brew analytics off")
def install_or_upgrade_package(package: str): if package not in _get_installed_packages(): shell.run(f"npm install --global {package}") else: shell.run(f"npm update --global {package}")
def upgrade_action(self): shell.run("asdf update")
def install_action(self): shell.run( f"git clone {' '.join(self.additional_clone_options)} {self.repo_url} {self.repo_path}" # noqa: E501 )