# scoop-tools **Repository Path**: abgox/scoop-tools ## Basic Information - **Project Name**: scoop-tools - **Description**: 为 Scoop 提供的工具,在下载应用时替换为指定的代理 URL,以提高下载速度 - **Primary Language**: PowerShell - **License**: MIT - **Default Branch**: main - **Homepage**: https://scoop-tools.abgox.com - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2025-05-28 - **Last Updated**: 2025-12-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: Scoop, install, script, update, tools ## README

scoop-tools

English | 简体中文 | Github | Gitee

github stars license code size repo size created

---

喜欢这个项目?请给它一个 Star ⭐️ 或 赞赏 💰

> [!Tip] > > 推荐使用 [PSCompletions 中的 scoop/scoop-install/scoop-update 命令补全](https://gitee.com/abgox/PSCompletions) ## 介绍 - 为 [Scoop](https://scoop.sh) 提供的工具,允许你在通过 Scoop 下载应用程序时,使用替换后的 URL 而非原始 URL。 - 你可以使用它们替换指定格式的 URL,从而通过代理地址加速下载。 - 典型的使用场景: 替换 `https://github.com` 和 `https://raw.githubusercontent.com` 为代理地址,参考 [使用](#使用) ## 安装 - 添加 [abyss](https://abyss.abgox.com) bucket ([Github](https://github.com/abgox/abyss) 或 [Gitee](https://gitee.com/abgox/abyss)) ```shell scoop bucket add abyss https://gitee.com/abgox/abyss ``` ```shell scoop bucket add abyss https://github.com/abgox/abyss ``` - 安装 `scoop-install` ```shell scoop install abyss/abgox.scoop-install ``` - 安装 `scoop-update` ```shell scoop install abyss/abgox.scoop-update ``` ## 使用 > [!Tip] > > Scoop 配置 > > - `abgox-scoop-install-url-replace-from`: 需要被替换的 url,使用正则表达式,用 `^` 限制匹配行首 > - `abgox-scoop-install-url-replace-to`: 用于替换的 url,必须和 `abgox-scoop-install-url-replace-from` 相对应 1. 设置 url 替换配置,如果有多个值,使用 `|||` 分割 ```shell scoop config abgox-scoop-install-url-replace-from "^https://github.com|||^https://raw.githubusercontent.com" ``` ```shell scoop config abgox-scoop-install-url-replace-to "https://gh-proxy.com/github.com|||https://gh-proxy.com/raw.githubusercontent.com" ``` 2. 使用 [PSCompletions](https://gitee.com/abgox/PSCompletions) 添加命令补全 ```shell scoop install abyss/abgox.PSCompletions ``` ```shell Import-Module PSCompletions ``` ```shell psc add scoop-install scoop-update ``` 3. 使用 `scoop-install` 命令安装应用 ```shell scoop-install abyss/abgox.scoop-i18n ``` 4. 使用 `scoop-update` 命令更新应用 ```shell scoop-update abyss/abgox.scoop-i18n ``` --- - `scoop-install` 可以使用 `-reset` 参数和 `scoop install` 命令的所有参数 - `scoop-update` 可以使用 `-reset` 参数和 `scoop update` 命令的所有参数 - 参考示例: - 如果你想撤销所有 bucket 中的本地文件更改,避免 `scoop update` 出现远程同步冲突 - 它使用 `git stash` 实现 - 如果你还需要这些更改,可以使用 `git stash pop` - 详情参考 [git stash](https://git-scm.com/docs/git-stash) ```shell scoop-install -reset ``` - 如果你想在安装 `abyss/abgox.scoop-i18n` 时不更新 Scoop,可以使用 `-u` 或 `--no-update-scoop` ```shell scoop-install abyss/abgox.scoop-i18n -u ``` - 如果你还不想使用下载缓存,可以使用 `-k` 或 `--no-cache` ```shell scoop-install abyss/abgox.scoop-i18n -u --no-cache ``` ## 实现原理 > [!Tip] > > - 以 `scoop-install` 为例 > - 当你运行 `scoop-install abyss/abgox.scoop-i18n` 时,`scoop-install` 会执行以下逻辑 1. `scoop-install` 会读取以下两个配置项的值 - `abgox-scoop-install-url-replace-from` - `abgox-scoop-install-url-replace-to` 2. `scoop-install` 会根据配置项的值替换 `abyss/abgox.scoop-i18n` 的清单文件中的 url - 假如你使用了以下配置 - `abgox-scoop-install-url-replace-from` 的值为 `^https://github.com|||^https://raw.githubusercontent.com` - `abgox-scoop-install-url-replace-to` 的值为 `https://gh-proxy.com/github.com|||https://gh-proxy.com/raw.githubusercontent.com` - 它会根据 `|||` 进行分割,然后分别对 url 进行替换 - `^https://github.com` 匹配 `https://github.com` 开头的 url,然后替换为 `https://gh-proxy.com/github.com` - `^https://raw.githubusercontent.com` 匹配 `https://raw.githubusercontent.com` 开头的 url,然后替换为 `https://gh-proxy.com/raw.githubusercontent.com` 3. 替换完成后,`scoop-install` 才会执行实际的 `scoop install` 命令 - 由于清单中的 url 已经替换为了 `https://gh-proxy.com` - 所以 Scoop 会从 `https://gh-proxy.com` 下载安装包 4. 当安装完成或使用 `Ctrl + C` 终止安装后,`scoop-install` 会自动撤销 `abyss/abgox.scoop-i18n` 的清单文件中的本地更改 - 如果安装过程中,直接关掉终端,`scoop-install` 无法继续撤销本地更改 - 这可能导致因为本地残留的临时更改,`scoop update` 无法正常的同步远程 bucket 仓库 - 此时,你需要运行 `scoop-install -reset`,它会撤销所有 bucket 中的本地文件更改 - 它使用 `git stash` 实现 - 如果你还需要这些更改,可以使用 `git stash pop` - 详情参考 [git stash](https://git-scm.com/docs/git-stash)