Windows 命令行包管理工具scoop的使用

参考资料

  1. 全Scoopコマンド解説 その1 ~使用頻度(高)~
  2. 個人的によく使うScoopコマンド
  3. WindowsコマンドラインツールScoopのすすめ(バージョン管理編)
  4. scoop中使用aria2加速下载

目录

  • [一. 简介](#一. 简介)
    • [1.1 安装](#1.1 安装)
      • [1.1.1 默认安装](#1.1.1 默认安装)
      • [1.1.2 安装到指定目录下](#1.1.2 安装到指定目录下)
      • [1.1.3 安装后修改安装目录](#1.1.3 安装后修改安装目录)
    • [1.2 目录结构](#1.2 目录结构)
    • [1.3 国内使用](#1.3 国内使用)
      • [1.3.1 使用国内 Bucket 镜像](#1.3.1 使用国内 Bucket 镜像)
      • [1.3.2 使用Aria2开启多线程下载](#1.3.2 使用Aria2开启多线程下载)
      • [1.3.3 设置代理](#1.3.3 设置代理)
  • [二. scoop常用操作](#二. scoop常用操作)
    • [2.1 bucket](#2.1 bucket)
    • [2.2 检索](#2.2 检索)
    • [2.3 安装](#2.3 安装)
      • [2.3.1 命令行工具](#2.3.1 命令行工具)
      • [2.3.2 软件开发环境](#2.3.2 软件开发环境)
    • [2.4 查看](#2.4 查看)
      • [2.4.1 查看scoop的整体状态](#2.4.1 查看scoop的整体状态)
      • [2.4.2 查看已经安装的所有软件](#2.4.2 查看已经安装的所有软件)
      • [2.4.3 查看指定软甲的相关信息](#2.4.3 查看指定软甲的相关信息)
      • [2.4.4 查看软件的安装位置](#2.4.4 查看软件的安装位置)
      • [2.4.5 查看所有的shim](#2.4.5 查看所有的shim)
      • [2.4.6 查看当前使用的命令的路径](#2.4.6 查看当前使用的命令的路径)
    • [2.5 更新](#2.5 更新)
    • [2.6 版本管理](#2.6 版本管理)
    • [2.7 卸载](#2.7 卸载)
    • [2.8 导入与导出](#2.8 导入与导出)
  • [三. 别名配置](#三. 别名配置)

一. 简介

🔷Scoop 是一个开源的 Windows 包管理器,通过用命令行管理开发工具,类似于Linux的apt 和 macOS的Homebrew。

  • 官方Github仓库:https://github.com/ScoopInstaller/Scoop

1.1 安装

1.1.1 默认安装

🔷通过Powershell进行安装

powershell 复制代码
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

🔷安装成功之后,会默认将当前用户的scoop\shims目录添加到用户环境变量中

1.1.2 安装到指定目录下

  • 先配置环境变量,指定安装位置后,再执行安装命令
powershell 复制代码
# 当前用户系统变量
[Environment]::SetEnvironmentVariable(
    'SCOOP',
    'D:\Scoop',
    [EnvironmentVariableTarget]::User
)

# 系统变量
[Environment]::SetEnvironmentVariable(
    'SCOOP',
    'D:\Scoop',
    [EnvironmentVariableTarget]::Machine
)

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

1.1.3 安装后修改安装目录

🔷如果C盘空间吃紧,或者当前用户名含有汉字的情况下,可以将scoop目录移动到其他磁盘中。

  • 找到原目录后,直接剪切走即可
  • 然后修改环境变量

1.2 目录结构

🔷默认会安装在当前用户的scoop目录下

  • apps:用于存放安装的软件
  • buckets:软件仓库,默认的仓库是main,可自行添加
  • cache:缓存
  • persist:存放软件配置,用来保证软件升级后不丢失配置

🔷shims

当通过 Scoop 安装一个命令行工具(如 git)时,Scoop 并不会修改系统的 PATH 环境变量来直接指向该工具的实际可执行文件(.exe)。

Scoop 会在 shims 目录下创建一个同名的、轻量级的可执行文件(.exe)。系统 PATH 环境变量中只需添加 ~\scoop\shims 这一个路径。

当运行命令(例如 git)时,系统会先找到 shims 目录下的 git.exe,这个 git.exe程序会负责定位并启动 apps 目录下对应软件的真实 git.exe

  • 7z.shim实际指向的是apps目录下的7z.exe

1.3 国内使用

1.3.1 使用国内 Bucket 镜像

  • scoop国内镜像优化库:https://gitee.com/scoop-installer/scoop
bash 复制代码
# 删除默认的main所关联的仓库
scoop bucket rm main

# 添加国内的镜像库
scoop bucket add main https://gitee.com/scoop-installer/main.git
scoop bucket add extras https://gitee.com/scoop-installer/extras.git
scoop bucket add versions https://gitee.com/scoop-installer/versions.git

1.3.2 使用Aria2开启多线程下载

  • 下载并启用之后,下载大型软件的话,可以提升下载速度
bash 复制代码
scoop install aria2
scoop config aria2-enabled true
  • 查看配置
powershell 复制代码
PS F:\> scoop config

last_update        scoop_repo                              scoop_branch aria2-enabled
-----------        ----------                              ------------ -------------
2026/5/31 13:18:38 https://github.com/ScoopInstaller/Scoop master                True

1.3.3 设置代理

  • 如果有条件的话,可以使用代理
bash 复制代码
# 设置代理
scoop config proxy http://127.0.0.1:7890
# 查看代理
scoop config proxy
# 删除代理
scoop config rm proxy

二. scoop常用操作

2.1 bucket

  • 列出所有可安装的bucket
bash 复制代码
PS F:\> scoop bucket known
main
extras
versions
nirsoft
sysinternals
php
nerd-fonts
nonportable
java
games
PS F:\>
  • 列出已经安装的bucket
bash 复制代码
PS F:\> scoop bucket list

Name     Source                                     Updated           Manifests
----     ------                                     -------           ---------
main     https://github.com/ScoopInstaller/Main.git 2026/5/31 5:38:29      1552
extras   https://github.com/ScoopInstaller/Extras   2026/5/31 3:20:12      2304
versions https://github.com/ScoopInstaller/Versions 2026/5/31 6:18:08       586
  • 添加指定的bucket
bash 复制代码
scoop bucket add extras
scoop bucket add versions
scoop bucket add java
  • 移除指定的bucket
bash 复制代码
scoop bucket rm java

2.2 检索

bash 复制代码
PS F:\> scoop search grep
Results from local buckets...

Name       Version    Source Binaries
----       -------    ------ --------
ast-grep   0.43.0     main
gettext    1.0-v1.19  main   msggrep.exe
gow        0.8.0      main   egrep.exe | fgrep.exe | grep.exe
grep       3.11       main
igrep      1.3.0      main
jsongrep   0.9.0      main
nim        2.2.10     main   nimgrep.exe
pcre2grep  10.39      main
pcregrep   8.45       main
repgrep    0.16.1     main
rga        0.10.9     main   ripgrep-all.exe
ripgrep    15.1.0     main
rktools2k3 1.0        main   qgrep.exe
ugrep      7.8.2      main
unxutils   2007.03.01 main   agrep.exe | egrep.exe | fgrep.exe | grep.exe
astrogrep  4.4.9      extras
baregrep   3.50a      extras
dngrep     4.7.54.0   extras
grepwin    2.1.12     extras
roughgrep  3.16.2     extras

2.3 安装

2.3.1 命令行工具

🔷所有的安装包都依赖于7zip解压缩,属于必安装的软件

bash 复制代码
scoop install 7zip

🔷coreutils提供了大多数常用的命令行工具

bash 复制代码
scoop install less
scoop install touch
scoop install coreutils

🔷文本处理3剑客

bash 复制代码
scoop install grep 
scoop install gawk
scoop install sed

🔷更加现代化的命令行工具

  • ripgrep用于代替grep
  • fd用于代替find,在windows中使用的话,find会乱码
  • bat用于代替cat
  • eza用于代替ls
bash 复制代码
scoop install ripgrep
scoop install fd
scoop install bat
scoop install eza

2.3.2 软件开发环境

bash 复制代码
scoop install sudo
bash 复制代码
scoop install vscode
scoop install eclipse-java
scoop install notepadplusplus
bash 复制代码
scoop install python313
scoop install python314

scoop install nodejs22
scoop install nodejs24
bash 复制代码
scoop install openjdk17
scoop install openjdk21

2.4 查看

2.4.1 查看scoop的整体状态

bash 复制代码
PS F:\> scoop status
Scoop is up to date.
Everything is ok!

2.4.2 查看已经安装的所有软件

bash 复制代码
PS F:\> scoop list
Installed apps:

Name      Version      Source Updated             Info
----      -------      ------ -------             ----
7zip      26.01        main   2026-05-30 14:00:24
bat       0.26.1       main   2026-05-31 08:29:50
coreutils 5.97.3       main   2026-05-30 14:22:33
eza       0.23.4       main   2026-05-30 19:40:30
fd        10.4.2       main   2026-05-30 19:23:59
ripgrep   15.1.0       main   2026-05-30 20:01:15
sudo      0.2020.01.26 main   2026-05-30 15:17:11
touch     0.2018.07.25 main   2026-05-31 08:28:36

2.4.3 查看指定软甲的相关信息

bash 复制代码
PS F:\> scoop info 7zip

Name        : 7zip
Description : A multi-format file archiver with high compression ratios.
Version     : 26.01
Source      : main
Website     : https://www.7-zip.org
License     : BSD-2-Clause, BSD-3-Clause, LGPL-2.1-or-later
Updated at  : 2026/4/28 1:55:41
Updated by  : github-actions[bot]
Installed   : 26.01
Binaries    : 7z.exe | 7zG.exe | 7zFM.exe
Shortcuts   : 7-Zip\7-Zip File Manager | 7-Zip\7-Zip Help
Notes       : To register the context menu entry, please execute the following command:
              reg import "<root>\install-context.reg"

              If an error occurs while attempting to delete files during uninstallation, run the following command and then retry:
              Stop-Process -Name 'explorer'

2.4.4 查看软件的安装位置

bash 复制代码
PS F:\> scoop prefix 7zip
C:\Users\用户名\scoop\apps\7zip\current

2.4.5 查看所有的shim

bash 复制代码
PS F:\> scoop shim list | head

Name      Source    Alternatives        IsGlobal IsHidden
----      ------    ------------        -------- --------
7z        External                      False    True
7zfm      External                      False    True
7zg       External                      False    True
basename  External                      False    True
bat       External                      False    True
cat       External                      False    True
chmod     External                      False    True

2.4.6 查看当前使用的命令的路径

  • 若系统中有多个版本的grep命令的话,使用scoop which,可以明确当前使用的grep安装路径
bash 复制代码
PS F:\> scoop which grep
C:\Program Files\Git\usr\bin\grep.exe

2.5 更新

  • 更新scoop自身,查看是否有软件可更新
bash 复制代码
PS F:\> scoop update
Updating Scoop...
Updating Buckets...
Scoop was updated successfully!
  • 更新指定的软件
bash 复制代码
PS F:\> scoop update 7zip
7zip: 26.01 (latest version)
Latest versions for all apps are installed! For more information try 'scoop status'

2.6 版本管理

🔷当安装了多个版本的软件后,可通过reset命令切换版本。

  • scoop reset python版本

2.7 卸载

bash 复制代码
# 卸载
scoop uninstall findutils
# 清除缓存
scoop cache rm findutils

2.8 导入与导出

bash 复制代码
# 将安装的软件列表导出
scoop export > scoop.json
# 依据导出的软件列表导入软甲
scoop import scoop.json

三. 别名配置

🔷Windows使用的是Powershell7,在C:\Users\用户名\Documents\PowerShell\profile.ps1的路径中新建profile.ps1文件。

  • 创建ll函数,用来封装eza命令
  • 文件夹优先,并且显示详细
powershell 复制代码
function ll {
    $eza = Join-Path $env:SCOOP 'shims\eza.exe'
    & $eza `
        -lah `
        --group-directories-first `
        @args
}
相关推荐
思麟呀1 小时前
C++11并发编程:互斥锁
linux·开发语言·c++·windows
xiaoliuliu123452 小时前
LaTeX 2023 (TeX Live + TeXstudio) 安装与汉化教程 Windows版:自定义路径+编辑器配置指南
windows·编辑器
技术达芬奇2 小时前
如何让 WSL 2 在后台持续运行:彻底解决关闭终端后 WSL 退出问题(Hermes Agent 持续运行)
windows·agent
一个人旅程~3 小时前
完整精华版macbookHighSierra 至Montere-Ventyra版本跨越评估与避坑指南(含证书有效期)
windows·经验分享·macos·电脑
Cheng小攸3 小时前
【无标题】
windows
Cheng小攸3 小时前
综合实战(3)
windows·php
bucenggaibian4 小时前
搭建CMD编译C语言环境
linux·c语言·windows
ylscode4 小时前
微软发布针对 Windows 11 的 KB5089573 补丁,以修复“周二补丁日”安装问题
windows·安全·microsoft·安全威胁分析
yaoxin52112314 小时前
419. 现代 Java IO 最佳实践 - 写入文本文件
java·windows·python