windows下的scoop的一些使用

scoop是什么

简而言之scoop是一个包管理工具, 可以在命令行安装一些软件

scoop项目地址:
lukesampson/scoop: A command-line installer for Windows. (github.com)

安装scoop

powershell中执行:

Invoke-Expression (New-Object System.Net.WebClient).DownloadString(‘https://get.scoop.sh‘)

我却提示:

PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass] to run Scoop.
For example, to set the execution policy to ‘RemoteSigned‘ please run :
‘Set-ExecutionPolicy RemoteSigned -scope CurrentUser‘

于是按照提示执行(执行完后无输出表示执行成功):

Set-ExecutionPolicy RemoteSigned -scope CurrentUser

接着继续执行:

Invoke-Expression (New-Object System.Net.WebClient).DownloadString(‘https://get.scoop.sh‘)

如下输出表示成功:

Initializing...
Downloading scoop...
Extracting...
Creating shim...
Downloading main bucket...
Extracting...
Adding ~\scoop\shims to your path.
‘lastupdate‘ has been set to ‘2021-05-20T09:37:03.5173303+08:00‘
Scoop was installed successfully!
Type ‘scoop help‘ for instructions.

验证scoop是否安装成功执行:

scoop help

输出:

Usage: scoop <command> \[<args>\]  
  
alias       Manage scoop aliases  
bucket      Manage Scoop buckets  
cache       Show or clear the download cache  
checkup     Check for potential problems  
cleanup     Cleanup apps by removing old versions  
config      Get or set configuration values  
create      Create a custom app manifest  
export      Exports (an importable) list of installed apps  
hold        Hold an app to disable updates  
home        Opens the app homepage  
install     Install apps  
prefix      Returns the path to the specified app  
reset       Reset an app to resolve conflicts  
search      Search available apps  
status      Show status and check for new app versions  
unhold      Unhold an app to enable updates  
uninstall   Uninstall an app  
update      Update apps, or Scoop itself  
virustotal  Look for app‘s hash on virustotal.com  
which       Locate a shim/executable (similar to ‘which‘ on Linux)  
  
  
Type ‘scoop help <command>‘ to get help for a specific command.

上面列出了很多scoop的用法, 比如scoop search 所搜可用的包, 然后就可以scoop install app-name安装

sudo

如果要用管理员运行命令,无需用管理员打开cmd(or powershell) 直接在命令行前加一个sudo即可.
安装sudo

scoop install sudo

grep

scoop install grep

安装完之后就可以在windows的终端使用grep

ls | grep something

aria2

Scoop可以利用aria2来使用多连接下载。只需通过Scoop安装aria2,之后所有下载都将使用它。

aria2是什么

aria2 是一个跨平台的快速而且可靠的下载工具,支持HTTP(S)、FTP、BitTorrent、Metalink 等协议. 可以从多个来源/协议下载文件,并尝试利用最大下载带宽

安装

scoop install aria2

输出:

Installing ‘aria2‘ (1.35.0-1) [64bit]
aria2-1.35.0-win-64bit-build1.zip (2.1 MB) [==================================================================] 100%
Checking hash of aria2-1.35.0-win-64bit-build1.zip ... ok.
Extracting aria2-1.35.0-win-64bit-build1.zip ... done.
Linking ~\scoop\apps\aria2\current => ~\scoop\apps\aria2\1.35.0-1
Creating shim for ‘aria2c‘.
‘aria2‘ (1.35.0-1) was installed successfully!

aria2配置
可以通过 scoop config 命令来配置aria2:

e.g.

# aria2-enabled 为key, false 为value(值)
scoop config aria2-enabled false

oh-my-posh

参考: Home | Oh my Posh
安装oh-my-posh

 scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

输出显示无法连接到远程服务器:

WARN  Scoop uses ‘aria2c‘ for multi-connection downloads.
WARN  Should it cause issues, run ‘scoop config aria2-enabled false‘ to disable it.
Installing ‘7zip‘ (19.00) [64bit]
Starting download with aria2 ...
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: e12626|OK  |   0.9MiB/s|C:/Users/19154/scoop/cache/7zip#19.00#https_7-zip.org_a_7z1900-x64.msi
Download: Status Legend:
Download: (OK):download completed.
Checking hash of 7z1900-x64.msi ... ok.
Extracting 7z1900-x64.msi ... done.
Linking ~\scoop\apps\7zip\current => ~\scoop\apps\7zip\19.00
Creating shim for ‘7z‘.
Creating shortcut for 7-Zip (7zFM.exe)
‘7zip‘ (19.00) was installed successfully!
WARN  error: 无法连接到远程服务器
Couldn‘t find manifest for ‘oh-my-posh‘ at the URL https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json.

在终端开启代理之后还是不行:

WARN  error: 无法连接到远程服务器
Couldn‘t find manifest for ‘https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json‘.

于是我直接用浏览器访问这个json文件却是可以下载的. 把它下载到本地之后继续执行命令(install后面的参数改为本地路径):

scoop install .\oh-my-posh.json

以下就是安装oh-my-posh的json文件内容:

{
  "version": "3.151.0",
  "description": "A prompt theme engine for any shell",
  "homepage": "https://ohmyposh.dev",
  "license": {
      "identifier": "GPL-3.0-only",
      "url": "https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/COPYING"
  },
  "architecture": {
      "64bit": {
          "url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v3.151.0/posh-windows-wsl-amd64.7z",
          "hash": "60A1B5ED3DDE7D0D6C16BA19DF5C70F934FCEE4371D4680862DD7699BE6AF4C6"
      }
  },
  "env_add_path": "bin",
  "checkver": {
      "github": "https://github.com/JanDeDobbeleer/oh-my-posh"
  },
  "post_install": [
      "Write-Host ‘Thanks for installing Oh my Posh.‘",
      "Write-Host ‘Have a look at https://ohmyposh.dev/docs/installation for detailed instructions for your shell.‘"
  ],
  "autoupdate": {
      "architecture": {
          "64bit": {
              "url": "https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v$version/posh-windows-wsl-amd64.7z",
              "hash": {
                  "url": "$url.sha256"
              }
          }
      }
  }
}

执行完毕之后输出:

WARN  Scoop uses ‘aria2c‘ for multi-connection downloads.
WARN  Should it cause issues, run ‘scoop config aria2-enabled false‘ to disable it.
Installing ‘oh-my-posh‘ (3.151.0) [64bit]
Starting download with aria2 ...
Download: Download Results:
Download: gid   |stat|avg speed  |path/URI
Download: ======+====+===========+=======================================================
Download: a3283d|OK  |   167KiB/s|C:/Users/19154/scoop/cache/oh-my-posh#3.151.0#https_github.com_JanDeDobbeleer_oh-my-posh_releases_download_v3.151.0_posh-windows-wsl-amd64.7z
Download: Status Legend:
Download: (OK):download completed.
Checking hash of posh-windows-wsl-amd64.7z ... ok.
Extracting posh-windows-wsl-amd64.7z ... done.
Linking ~\scoop\apps\oh-my-posh\current => ~\scoop\apps\oh-my-posh\3.151.0
Running post-install script...
Thanks for installing Oh my Posh.
Have a look at https://ohmyposh.dev/docs/installation for detailed instructions for your shell.
‘oh-my-posh‘ (3.151.0) was installed successfully!

更新oh-my-p

scoop update oh-my-posh

使用oh-my-posh的主题

主题预览
Themes | Oh my Posh
一. 执行$PROFILE`会输出powershell的配置文件路径,如果没有就新建一个

C:\Users\19154\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

二. 在配置文件中追加一行如下代码:

oh-my-posh --init --shell pwsh --config ~/.mytheme.omp.json | Invoke-Expression

其中~/.mytheme.omp.json是本地的主题文件, 路径在~\scoop\apps\oh-my-posh\current\themes\
三. 执行. $PROFILE命令使配置文件生效

四. oh-my-posh 安装成功之后, 所有的主题存在~\scoop\apps\oh-my-posh\current\themes\文件夹下(就是一些json文件).

    目录: C:\Users\19154\scoop\apps\oh-my-posh\current\themes


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
------       2021-05-18     18:48           1640 agnoster.omp.json
------       2021-05-18     18:48           1332 agnosterplus.omp.json
------       2021-05-18     18:48           1213 aliens.omp.json
------       2021-05-18     18:48           1145 avit.omp.json
------       2021-05-18     18:48           3417 blueish.omp.json
------       2021-05-18     18:48           5216 bubbles.omp.json
------       2021-05-18     18:48           4278 bubblesline.omp.json
------       2021-05-18     18:48           1713 cert.omp.json
------       2021-05-18     18:48           1840 cinnamon.omp.json
------       2021-05-18     18:48           1592 darkblood.omp.json
------       2021-05-18     18:48           1444 emodipt.omp.json
------       2021-05-18     18:48           1438 fish.omp.json
------       2021-05-18     18:48           2708 gmay.omp.json
------       2021-05-18     18:48           1709 half-life.omp.json
------       2021-05-18     18:48           2083 honukai.omp.json
------       2021-05-18     18:48           1824 hotstick.minimal.omp.json
------       2021-05-18     18:48           2718 huvix.omp.json
------       2021-05-18     18:48           6515 jandedobbeleer.omp.json
------       2021-05-18     18:48           4869 jonnychipz.omp.json
------       2021-05-18     18:48            784 lambda.omp.json
------       2021-05-18     18:48           1862 marcduiker.omp.json
------       2021-05-18     18:48           1349 material.omp.json
------       2021-05-18     18:48           2655 microverse-power.omp.json
------       2021-05-18     18:48           2413 negligible.omp.json
------       2021-05-18     18:48           2250 nu4a.omp.json
------       2021-05-18     18:48           1981 paradox.omp.json
------       2021-05-18     18:48           1828 pararussel.omp.json
------       2021-05-18     18:48           4683 pixelrobots.omp.json
------       2021-05-18     18:48           2332 powerlevel10k_classic.omp.json
------       2021-05-18     18:48           1119 powerlevel10k_lean.omp.json
------       2021-05-18     18:48           2629 powerlevel10k_modern.omp.json
------       2021-05-18     18:48           6245 powerlevel10k_rainbow.omp.json
------       2021-05-18     18:48           1418 powerline.omp.json
------       2021-05-18     18:48           2116 pure.omp.json
------       2021-05-18     18:48           1348 remk.omp.json
------       2021-05-18     18:48           1160 robbyrussel.omp.json
------       2021-05-18     18:48          55688 schema.json
------       2021-05-18     18:48           6014 slim.omp.json
------       2021-05-18     18:48           5857 slimfat.omp.json
------       2021-05-18     18:48           1366 sorin.omp.json
------       2021-05-18     18:48           2930 space.omp.json
------       2021-05-18     18:48           1239 spaceship.omp.json
------       2021-05-18     18:48           1652 star.omp.json
------       2021-05-18     18:48           3832 stelbent.minimal.omp.json
------       2021-05-18     18:48           2579 ys.omp.json
------       2021-05-18     18:48           1464 zash.omp.json

windows下的scoop的一些使用

上一篇:WPF 入门 (一) XAML 基础知识


下一篇:Win32 处理多个按钮共用一个事件消息