コード例 #1
0
ファイル: git.py プロジェクト: samueljsb/qaz
    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}")
コード例 #2
0
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}")
コード例 #3
0
ファイル: cli.py プロジェクト: samueljsb/qaz
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)
コード例 #4
0
ファイル: zsh.py プロジェクト: samueljsb/qaz
    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()
コード例 #5
0
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}")
コード例 #6
0
ファイル: zsh.py プロジェクト: samueljsb/qaz
    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()
コード例 #7
0
    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}")
コード例 #8
0
ファイル: zsh.py プロジェクト: samueljsb/qaz
    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}")
コード例 #9
0
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)
コード例 #10
0
 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
     )
コード例 #11
0
ファイル: zsh.py プロジェクト: samueljsb/qaz
 def install_action(self):
     shell.run("sudo apt update")
     shell.run("sudo apt install --yes zsh")
     self._set_default_shell()
コード例 #12
0
ファイル: brew.py プロジェクト: samueljsb/qaz
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}")
コード例 #13
0
 def upgrade_action(self):
     shell.run("poetry self update")
コード例 #14
0
def install_or_upgrade_package(package: str):
    shell.run(f"python -m pip install --upgrade {package}")
コード例 #15
0
ファイル: brew.py プロジェクト: samueljsb/qaz
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}")
コード例 #16
0
ファイル: git.py プロジェクト: samueljsb/qaz
 def install_action(self):
     super().install_action()
     shell.run("gh auth login --web")
コード例 #17
0
 def upgrade_action(self):
     shell.run(str(config.get_root_dir() / "scripts" / "set-defaults.sh"))
コード例 #18
0
ファイル: brew.py プロジェクト: samueljsb/qaz
 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")
コード例 #19
0
ファイル: git.py プロジェクト: samueljsb/qaz
 def upgrade_action(self):
     shell.run(f"git -C {self.repo_path} pull")
コード例 #20
0
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
コード例 #21
0
ファイル: vim.py プロジェクト: samueljsb/qaz
 def upgrade_action(self):
     super().upgrade_action()
     shell.run("vim +PluginInstall +qall")
コード例 #22
0
ファイル: vim.py プロジェクト: samueljsb/qaz
 def install_action(self):
     super().install_action()
     shell.run("vim +PluginInstall +qall")
コード例 #23
0
ファイル: zsh.py プロジェクト: samueljsb/qaz
 def upgrade_action(self):
     shell.run("sudo apt update")
     shell.run("sudo apt upgrade --yes zsh")
     self._set_default_shell()
コード例 #24
0
    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}")
コード例 #25
0
ファイル: brew.py プロジェクト: samueljsb/qaz
 def upgrade_action(self):
     shell.run("brew update")
     shell.run("brew analytics off")
コード例 #26
0
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}")
コード例 #27
0
 def upgrade_action(self):
     shell.run("asdf update")
コード例 #28
0
ファイル: git.py プロジェクト: samueljsb/qaz
 def install_action(self):
     shell.run(
         f"git clone {' '.join(self.additional_clone_options)} {self.repo_url} {self.repo_path}"  # noqa: E501
     )