-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
47 lines (42 loc) · 1.3 KB
/
Copy pathinstall.ps1
File metadata and controls
47 lines (42 loc) · 1.3 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
[CmdletBinding()]
param(
[Parameter(ValueFromRemainingArguments = $true)]
[string[]] $ChezmoiArguments
)
$ErrorActionPreference = 'Stop'
$promptRoles = $false
if ($ChezmoiArguments.Count -gt 0 -and $ChezmoiArguments[0] -eq '--prompt-roles') {
$promptRoles = $true
$ChezmoiArguments = @($ChezmoiArguments | Select-Object -Skip 1)
}
$chezmoi = Get-Command chezmoi -ErrorAction SilentlyContinue
if (-not $chezmoi) {
$binDirectory = Join-Path $HOME '.local/bin'
Write-Host "Installing chezmoi to '$binDirectory'" -ForegroundColor Cyan
& ([scriptblock]::Create((Invoke-RestMethod 'https://get.chezmoi.io/ps1'))) -b $binDirectory
$chezmoiPath = Join-Path $binDirectory 'chezmoi.exe'
} else {
$chezmoiPath = $chezmoi.Source
}
$roles = 'development,desktop,secrets'
if ($promptRoles) {
$selection = Read-Host "Roles (development,desktop,gaming,secrets,work) [$roles]"
if ($selection -eq '-') {
$roles = ''
} elseif ($selection) {
$roles = $selection
}
}
$source = $PSScriptRoot
Push-Location $HOME
try {
& $chezmoiPath init --apply --verbose --no-tty `
--promptString "Roles=$roles" `
"--source=$source" @ChezmoiArguments
$chezmoiExitCode = $LASTEXITCODE
} finally {
Pop-Location
}
if ($chezmoiExitCode -ne 0) {
exit $chezmoiExitCode
}