-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.ps1
More file actions
51 lines (43 loc) · 1.42 KB
/
install.ps1
File metadata and controls
51 lines (43 loc) · 1.42 KB
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
function ConfirmInstallScript {
[CmdletBinding()]
param([string] $Name, [string] $Script)
end {
$bat = Get-Command bat -CommandType Application -ErrorAction Ignore
$batArgs = @('-l', 'powershell')
if (-not $bat) {
$bat = 'more'
$batArgs = @()
}
$Script | & $bat @batArgs
if (-not $PSCmdlet.ShouldContinue('Or is it bad now :o', "Install ${Name}?")) {
throw 'it''s bad now :o'
}
& ([scriptblock]::Create($Script))
}
}
# This script will likely be iex'd. So usually this in a script doesn't
# make any sense, but it does here.
try { Set-ExecutionPolicy -Scope CurrentUser Unrestricted } catch { }
if (-not (Get-Command scoop -CommandType Application -ErrorAction Ignore)) {
$scoopInstall = (Invoke-WebRequest -UseBasicParsing get.scoop.sh).Content
ConfirmInstallScript scoop $scoopInstall
}
scoop install git chezmoi
if (-not $env:NO_SECRETS) {
scoop install bitwarden-cli
$status = $null
do
{
if ($status) {
Write-Error 'Login failed, try again'
}
$status = bw status | ConvertFrom-Json
if ($status.userEmail) {
$env:BW_SESSION = bw unlock --raw
} else {
$env:BW_SESSION = bw login --raw
}
} while (-not $env:BW_SESSION)
}
chezmoi init SeeminglyScience
chezmoi apply -v