-
Notifications
You must be signed in to change notification settings - Fork 3
/
scoop-up.ps1
81 lines (72 loc) · 2.69 KB
/
scoop-up.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<#
Installs scoop & scoop packages from a file.
Any lines marked with a # at the start of the line are ignored.
#>
param(
[string]
$filename = "scoop-base.packages",
[switch] $configure
)
# src: https://stackoverflow.com/a/2688572
function Write-Color([String[]]$Text, [ConsoleColor[]]$Color) {
for ($i = 0; $i -lt $Text.Length; $i++) {
Write-Host $Text[$i] -Foreground $Color[$i] -NoNewLine
}
Write-Host
}
function Add-Bucket([String] $bucket) {
Write-Color -Text "Checking Scoop bucket ", $bucket, '...' -Color DarkCyan,Magenta,DarkCyan
if (-Not (Test-Path $env:USERPROFILE\scoop\buckets\$bucket)) {
Write-Color -Text "Adding Scoop Bucket ", $bucket -Color DarkCyan,Magenta
scoop bucket add $bucket
} else {
Write-Color "Scoop bucket ", $bucket , " exists!" -Color Green, Magenta, Green
}
}
function Add-Alias([String] $alias, [String] $command) {
$aliases = scoop alias list | Select-Object -ExpandProperty Name
if (-Not ($aliases -contains $alias)) {
Write-Color "Adding Scoop Alias ", $alias, " ", $command -Color DarkCyan, Magenta, DarkCyan, Green
scoop alias add $alias $command
} else {
Write-Color "Scoop alias ", $alias , " exists!" -Color Green, Magenta, Green
}
}
Write-Color "Checking Scoop installed..." -Color DarkCyan
# Check if Scoop is installed, if not, install it
if (-Not (Test-Path $env:USERPROFILE\scoop)) {
Write-Color "Installing Scoop..." -Color Red
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
} else {
Write-Color "Scoop installed already!" -Color Green
}
# Check default buckets
# src: https://github.com/ScoopInstaller/Scoop/blob/master/buckets.json
Add-Bucket "extras"
Add-Bucket "sysinternals"
Add-Bucket "nerd-fonts"
Add-Alias "upgrade-all" "scoop update '*'"
if ($configure.IsPresent)
{
Write-Color "Completed Configuring Scoop ", "successfully!" -Color DarkCyan,Green
Exit(0)
}
# Iterates through the file and install or upgrade the silently.
$install_totald = 0
$install_succes = 0
$install_failed = 0
(Get-Content $filename) -notmatch '^#' -match "\S" `
| ForEach-Object {
Write-Color -Text "Installing ", $_, '...' -Color DarkCyan,Magenta,DarkCyan
$install_totald++
scoop install $_
if( $? ){
Write-Color -Text "Installing ", $_, "...", "Success :)" -Color DarkCyan,Magenta,DarkCyan,Green
$install_succes++
}
if( !$? ){
Write-Color -Text "Installing ", $_, "...", "Failed :(" -Color DarkCyan,Magenta,DarkCyan,Red
$install_failed++
}
}
Write-Color "Completed Scoop'ing (", $install_totald , ") packages with (", $install_succes, ") succesful, (", $install_failed, ") failures." -Color DarkCyan,Magenta,DarkCyan,Green,DarkCyan,Red,DarkCyan