-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
46 lines (37 loc) · 1.34 KB
/
install.ps1
File metadata and controls
46 lines (37 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
param(
[string]$Repo = "eliophan/KeyboardClean",
[string]$Ref = "main",
[string]$InstallDir = "$env:LOCALAPPDATA\keyboard-clean"
)
$baseUrl = "https://raw.githubusercontent.com/$Repo/$Ref"
$scriptUrl = "$baseUrl/scripts/keyboard-clean-windows.ps1"
$scriptPath = Join-Path $InstallDir "keyboard-clean.ps1"
$cmdPath = Join-Path $InstallDir "keyboard-clean.cmd"
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Invoke-WebRequest -Uri $scriptUrl -OutFile $scriptPath
$cmdContent = @"
@echo off
set "SECONDS=%~1"
if "%SECONDS%"=="" (
powershell -NoProfile -ExecutionPolicy Bypass -File "$scriptPath"
) else (
powershell -NoProfile -ExecutionPolicy Bypass -File "$scriptPath" -Seconds %SECONDS%
)
"@
Set-Content -Path $cmdPath -Value $cmdContent -Encoding Ascii
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($null -eq $userPath) {
$userPath = ""
}
$normalizedPath = ";" + $userPath.TrimEnd(";") + ";"
if ($normalizedPath -notlike "*;$InstallDir;*") {
if ([string]::IsNullOrWhiteSpace($userPath)) {
$newPath = $InstallDir
} else {
$newPath = "$userPath;$InstallDir"
}
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
Write-Output "Added $InstallDir to User PATH."
}
Write-Output "Installed keyboard-clean for Windows."
Write-Output "Open a new terminal, then run: keyboard-clean 60"