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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM