Ubuntu上安裝軟件是apt-get install xxx,
Mac一般都推薦裝個brew之後,brew install xxx,
那麼來到Windows的時間就開始抓狂了,找下載鏈接下載exe,然後exe安裝完了之後有些東西還要配置什麼鬼環境變量(不用問我是撒了)。
問題來了,難道Windows沒有好用的軟件包管理工具呢?
(360軟件管家、騰訊軟件管家蠢蠢欲動...死變態,一邊去!!!)
答案是:有,請認準Chocolatey - The package manager for Windows
怎麼玩?如下:
Install with cmd.exe
Run the following command: (copy command text)
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
Install with PowerShell.exe
With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass
to bypass the policy to get things installed or AllSigned
for quite a bit more security.
- Run
Get-ExecutionPolicy
. If it returnsRestricted
, then runSet-ExecutionPolicy AllSigned
orSet-ExecutionPolicy Bypass -Scope Process
. - Now run the following command: (copy command text)
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
根據網絡情況可能需要一分鐘到幾分鐘不等,如果遇到超時失敗之類的,重試一下,再不行自行翻越長城。
需要JDK?
C:\> choco install jdk8
需要JDK9?
C:\> choco install jdk9
需要最新版Chrome?
C:\> choco install googlechrome
需要IDEA?
C:\> choco install intellijidea-community
需要Git?
C:\> choco install git
需要什麼軟件包可以再這裏Chocolatey Gallery | Packages搜索一下,美滋滋的。
什麼,install完了還需要配置什麼環境變量麼?
肯定是直接洗洗睡啊。
chocolatey是windows下的一個命令行的包管理工具,類似ubuntu的apt,或centos下的yum。
準備
在安裝之前,你先要將你的powershell設置爲允許執行遠程腳本:
Running as administrator
來打開PowerShell- 命令行裏輸入
Set-ExecutionPolicy RemoteSigned
安裝choco
詳細請查閱官方文檔,我是直接使用了最簡單的PowerShell v3+ 的安裝方式:
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
PowerShell輸入上面這代碼然後enter。
裝好了,然後呢?
然後你就能像ubuntu下apt-get那樣安裝你所需要的軟件/包了,例如你想裝個chrome:
choco install googlechrome
或者來個winrar:
choco install winrar
再來個nodejs?
choco install nodejs.install
更多可安裝的包可以查看這個網址:https://chocolatey.org/packages
參考文獻: