Scoop - 在Windows命令行上進行程序安裝

2019-01-28  22:49:21git

資料來源自Scoop官方網站以及github上的幫助文檔github

若是有疑惑或者以爲文章有錯誤請留言以幫助改正web


補充內容(2019-04-09 21:11:36):不會FQ的同窗仍是放棄吧,下載速度讓你崩潰。(換源?)shell

Scoop -- A command-line installer for Windows

是開發人員用來安裝程序用的,使用命令行進行操做。json

安裝前提(所須要的環境):

操做環境:win10。app

確保你的 PowerShell 版本 >= 3. win7或許低於3,得升級。oop

PowerShell在哪裏?如下三種方法可找到:gradle

  1. win + R 打開運行後輸入powershell而後肯定;(和環境變量有關)網站

  2. cmd中輸入powershell而後回車;(和環境變量有關)spa

  3. 在開始菜單中查找;

如何查看本身的PowerShell 版本呢?在PowerShell中輸入以下內容:

$psversiontable.psversion.major

本人電腦上顯示以下:

1 PS C:\Users\user> $psversiontable.psversion.major
2 5

而後確保你容許PowerShell執行本地腳本,在PowerShell中輸入以下內容,已完成執行策略的更改:

set-executionpolicy remotesigned -scope currentuser

遇到提示,輸入Y便可。

開始安裝Scoop.

在PowerShell中輸入以下內容(將會安裝到默認目錄C:\Users\user(本身的用戶名)\scoop,也可指定安裝目錄):

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

想要指定安裝目錄,在PowerShell中輸入以下內容(代碼中的D:\Applications\Scoop爲指定的目錄):

[environment]::setEnvironmentVariable('SCOOP','D:\Applications\Scoop','User')
$env:SCOOP='D:\Applications\Scoop'
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

等待安裝完成。。。

使用Scoop(在cmd和PowerShell中輸入如下命令都可,由於已經爲Scoop自動設置了環境變量)。

輸入如下命令查看Scoop命令的概述:

scoop help

結果顯示以下:

 1 PS C:\Users\15991> scoop help
 2 Usage: scoop <command> [<args>]
 3 
 4 Some useful commands are:
 5 
 6 alias       Manage scoop aliases
 7 bucket      Manage Scoop buckets
 8 cache       Show or clear the download cache
 9 checkup     Check for potential problems
10 cleanup     Cleanup apps by removing old versions
11 config      Get or set configuration values
12 create      Create a custom app manifest
13 depends     List dependencies for an app
14 export      Exports (an importable) list of installed apps
15 help        Show help for a command
16 home        Opens the app homepage
17 info        Display information about an app
18 install     Install apps
19 list        List installed apps
20 prefix      Returns the path to the specified app
21 reset       Reset an app to resolve conflicts
22 search      Search available apps
23 status      Show status and check for new app versions
24 uninstall   Uninstall an app
25 update      Update apps, or Scoop itself
26 virustotal  Look for app's hash on virustotal.com
27 which       Locate a shim/executable (similar to 'which' on Linux)
28 
29 
30 Type 'scoop help <command>' to get help for a specific command.

輸入'scoop help <command>'能夠查看具體的某個命令的用法,以下所示:

scoop help install

顯示結果以下:

 1 PS C:\Users\15991> scoop help install
 2 Usage: scoop install <app> [options]
 3 
 4 e.g. The usual way to install an app (uses your local 'buckets'):
 5      scoop install git
 6 
 7 To install an app from a manifest at a URL:
 8      scoop install https://raw.github.com/lukesampson/scoop/master/bucket/runat.json
 9 
10 To install an app from a manifest on your computer
11      scoop install \path\to\app.json
12 
13 When installing from your computer, you can leave the .json extension off if you like.
14 
15 Options:
16   -g, --global              Install the app globally
17   -i, --independent         Don't install dependencies automatically
18   -k, --no-cache            Don't use the download cache
19   -s, --skip                Skip hash validation (use with caution!)
20   -a, --arch <32bit|64bit>  Use the specified architecture, if the app supports it

查找要安裝的程序,如gradle:

scoop search gradle

顯示結果以下:

1 PS C:\Users\15991> scoop search gradle
2 'main' bucket:
3     gradle-bin (5.1.1)
4     gradle (5.1.1)

查找全部可用程序:

scoop search

 

安裝程序,如gradle,默認會安裝到Scoop安裝目錄下的apps目錄:

scoop install gradle

顯示結果以下:

1 PS C:\Users\15991> scoop install gradle
2 Installing 'gradle' (5.1.1) [32bit]
3 gradle-5.1.1-all.zip (124.7 MB) [>                                                        ]   1%

也可將程序安裝到指定目錄,如F:\GlobalScoopApps:

[environment]::setEnvironmentVariable('SCOOP_GLOBAL','F:\GlobalScoopApps','Machine')
$env:SCOOP_GLOBAL='F:\GlobalScoopApps'
scoop install -g <app>

對Scoop進行版本更新

scoop update

對Scoop安裝的全部程序進行更新(也可指定某個程序進行更新):

scoop update *
相關文章
相關標籤/搜索