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
参考文献: