-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
48 lines (34 loc) · 1.34 KB
/
install.ps1
File metadata and controls
48 lines (34 loc) · 1.34 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
# Install and configure system
# Install chezmoi if it doesn't exist
function Install-Chezmoi {
$binDir = "$env:USERPROFILE\.local\bin"
$chezmoi = Get-Command chezmoi -ErrorAction SilentlyContinue
# Check if chezmoi is already installed
if ($chezmoi) {
Write-Output $chezmoi.Source
return
}
$chezmoi = "$binDir\chezmoi"
# Get install script
if (Test-Path (Get-Command curl -ErrorAction SilentlyContinue)) {
$installScript = Invoke-WebRequest -Uri "https://chezmoi.io/get" -UseBasicParsing
} elseif (Test-Path (Get-Command wget -ErrorAction SilentlyContinue)) {
$installScript = Invoke-WebRequest -Uri "https://chezmoi.io/get" -UseBasicParsing
} else {
Write-Output "To install chezmoi, you must have curl or wget installed." 2>&1
exit 1
}
$installScript.Content | Invoke-Expression
Write-Output $chezmoi
}
#################### Main Program ####################
Set-StrictMode -Version Latest
# Get chezmoi
$chezmoi = Install-Chezmoi
# PowerShell way to get the script's directory
$scriptDir = Split-Path $MyInvocation.MyCommand.Path
$PSBoundParameters.Clear()
$PSBoundParameters.Add("source", $scriptDir)
# Replace the current process with chezmoi
Write-Output "Running 'chezmoi init --apply --source=$scriptDir'" 2>&1
Start-Process $chezmoi -ArgumentList "init", "--apply", "--source=$scriptDir" -Wait