Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ always work. Proxmox tools: `therepos/proxmox`; MCP servers: `therepos/mcp`; Cla
hidden or scheduled run) puts the window on the right half of its screen.
- `shortcut`: every script with a menu offers Settings > `Shortcut '<name>' [on/off]`. It saves a local
copy in `%LOCALAPPDATA%\<name>` and adds `function <name> { & "$env:LOCALAPPDATA\<name>\<name>.ps1" }`
to `$PROFILE`; nothing is fetched when it runs, and off/on refreshes the copy. Use `Show-ShortcutSettings`
to `$PROFILE`; nothing is fetched when it runs, and off/on downloads the latest copy (keeping the old one if the download fails). Use `Show-ShortcutSettings`
when the shortcut is the only setting, else `Test-Shortcut` / `Switch-Shortcut` in the script's Settings.
- Per-tool files (tools, settings, logs, local copy) go in `%LOCALAPPDATA%\<name>`, fetched without admin.
- Secrets: never hard-coded; ask once, save DPAPI-encrypted (`ConvertFrom-SecureString`) in `settings.json`.
Expand Down
37 changes: 31 additions & 6 deletions apps/appupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,24 @@ function Test-Shortcut {
(Test-Path -LiteralPath $PROFILE) -and (Test-Path -LiteralPath (Get-ShortcutCopy)) -and
(@(Get-Content -LiteralPath $PROFILE -ErrorAction SilentlyContinue) -contains (Get-ShortcutLine))
}
# Downloads the latest script over the local copy; the copy is only replaced by a complete download
function Save-ShortcutCopy($copy) {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$tmp = "$copy.new"
$raw = $ScriptUrl -replace '^https://github\.com/([^/]+/[^/]+)/raw/', 'https://raw.githubusercontent.com/$1/'
foreach ($url in $ScriptUrl, $raw, $ScriptUrl) {
try {
Invoke-WebRequest -Uri "${url}?$(Get-Random)" -OutFile $tmp -UseBasicParsing -ErrorAction Stop
if (Select-String -LiteralPath $tmp -SimpleMatch '$ScriptUrl' -Quiet) {
Move-Item -LiteralPath $tmp -Destination $copy -Force
return $true
}
} catch {}
Start-Sleep -Seconds 2
}
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
return $false
}
function Switch-Shortcut([switch]$KeepCopy) {
$name = Get-ShortcutName
$copy = Get-ShortcutCopy
Expand All @@ -640,16 +658,22 @@ function Switch-Shortcut([switch]$KeepCopy) {
@(Get-Content -LiteralPath $PROFILE) | Where-Object { $_ -notmatch "^function $name " } | Set-Content -LiteralPath $PROFILE
}
if ($on) {
if (-not $KeepCopy) { Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue }
if (-not $KeepCopy) {
# Kept in memory so a failed download on the next "on" can restore it
if (Test-Path -LiteralPath $copy) { $script:ShortcutKept = [IO.File]::ReadAllBytes($copy) }
Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue
}
Say " Shortcut removed." 'Green'
return
}
New-Item -ItemType Directory -Path (Split-Path -Path $copy -Parent) -Force | Out-Null
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
if ($PSCommandPath -ne $copy) { Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force }
} else {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "${ScriptUrl}?$(Get-Random)" -OutFile $copy -UseBasicParsing
$stale = $false
if ($PSCommandPath -and ($PSCommandPath -ne $copy) -and (Test-Path -LiteralPath $PSCommandPath)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force
} elseif (-not (Save-ShortcutCopy $copy)) {
if ($script:ShortcutKept -and -not (Test-Path -LiteralPath $copy)) { [IO.File]::WriteAllBytes($copy, $script:ShortcutKept) }
if (-not (Test-Path -LiteralPath $copy)) { throw 'the download failed. Check the connection and try again.' }
$stale = $true
}
Unblock-File -LiteralPath $copy -ErrorAction SilentlyContinue
if ((Get-ExecutionPolicy -Scope CurrentUser) -in 'Undefined', 'Restricted', 'AllSigned') {
Expand All @@ -658,6 +682,7 @@ function Switch-Shortcut([switch]$KeepCopy) {
if (-not (Test-Path -LiteralPath $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE "`n$(Get-ShortcutLine)"
Say " Shortcut added. In a new PowerShell window, just type: $name" 'Green'
if ($stale) { Say " Could not download the latest version; kept the previous copy." 'Yellow' }
} catch {
Say " Could not change the shortcut: $($_.Exception.Message)" 'Red'
}
Expand Down
37 changes: 31 additions & 6 deletions apps/filemap.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ function Test-Shortcut {
(Test-Path -LiteralPath $PROFILE) -and (Test-Path -LiteralPath (Get-ShortcutCopy)) -and
(@(Get-Content -LiteralPath $PROFILE -ErrorAction SilentlyContinue) -contains (Get-ShortcutLine))
}
# Downloads the latest script over the local copy; the copy is only replaced by a complete download
function Save-ShortcutCopy($copy) {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$tmp = "$copy.new"
$raw = $ScriptUrl -replace '^https://github\.com/([^/]+/[^/]+)/raw/', 'https://raw.githubusercontent.com/$1/'
foreach ($url in $ScriptUrl, $raw, $ScriptUrl) {
try {
Invoke-WebRequest -Uri "${url}?$(Get-Random)" -OutFile $tmp -UseBasicParsing -ErrorAction Stop
if (Select-String -LiteralPath $tmp -SimpleMatch '$ScriptUrl' -Quiet) {
Move-Item -LiteralPath $tmp -Destination $copy -Force
return $true
}
} catch {}
Start-Sleep -Seconds 2
}
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
return $false
}
function Switch-Shortcut([switch]$KeepCopy) {
$name = Get-ShortcutName
$copy = Get-ShortcutCopy
Expand All @@ -87,16 +105,22 @@ function Switch-Shortcut([switch]$KeepCopy) {
@(Get-Content -LiteralPath $PROFILE) | Where-Object { $_ -notmatch "^function $name " } | Set-Content -LiteralPath $PROFILE
}
if ($on) {
if (-not $KeepCopy) { Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue }
if (-not $KeepCopy) {
# Kept in memory so a failed download on the next "on" can restore it
if (Test-Path -LiteralPath $copy) { $script:ShortcutKept = [IO.File]::ReadAllBytes($copy) }
Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue
}
Say " Shortcut removed." 'Green'
return
}
New-Item -ItemType Directory -Path (Split-Path -Path $copy -Parent) -Force | Out-Null
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
if ($PSCommandPath -ne $copy) { Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force }
} else {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "${ScriptUrl}?$(Get-Random)" -OutFile $copy -UseBasicParsing
$stale = $false
if ($PSCommandPath -and ($PSCommandPath -ne $copy) -and (Test-Path -LiteralPath $PSCommandPath)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force
} elseif (-not (Save-ShortcutCopy $copy)) {
if ($script:ShortcutKept -and -not (Test-Path -LiteralPath $copy)) { [IO.File]::WriteAllBytes($copy, $script:ShortcutKept) }
if (-not (Test-Path -LiteralPath $copy)) { throw 'the download failed. Check the connection and try again.' }
$stale = $true
}
Unblock-File -LiteralPath $copy -ErrorAction SilentlyContinue
if ((Get-ExecutionPolicy -Scope CurrentUser) -in 'Undefined', 'Restricted', 'AllSigned') {
Expand All @@ -105,6 +129,7 @@ function Switch-Shortcut([switch]$KeepCopy) {
if (-not (Test-Path -LiteralPath $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE "`n$(Get-ShortcutLine)"
Say " Shortcut added. In a new PowerShell window, just type: $name" 'Green'
if ($stale) { Say " Could not download the latest version; kept the previous copy." 'Yellow' }
} catch {
Say " Could not change the shortcut: $($_.Exception.Message)" 'Red'
}
Expand Down
37 changes: 31 additions & 6 deletions apps/filesync.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ function Test-Shortcut {
(Test-Path -LiteralPath $PROFILE) -and (Test-Path -LiteralPath (Get-ShortcutCopy)) -and
(@(Get-Content -LiteralPath $PROFILE -ErrorAction SilentlyContinue) -contains (Get-ShortcutLine))
}
# Downloads the latest script over the local copy; the copy is only replaced by a complete download
function Save-ShortcutCopy($copy) {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$tmp = "$copy.new"
$raw = $ScriptUrl -replace '^https://github\.com/([^/]+/[^/]+)/raw/', 'https://raw.githubusercontent.com/$1/'
foreach ($url in $ScriptUrl, $raw, $ScriptUrl) {
try {
Invoke-WebRequest -Uri "${url}?$(Get-Random)" -OutFile $tmp -UseBasicParsing -ErrorAction Stop
if (Select-String -LiteralPath $tmp -SimpleMatch '$ScriptUrl' -Quiet) {
Move-Item -LiteralPath $tmp -Destination $copy -Force
return $true
}
} catch {}
Start-Sleep -Seconds 2
}
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
return $false
}
function Switch-Shortcut([switch]$KeepCopy) {
$name = Get-ShortcutName
$copy = Get-ShortcutCopy
Expand All @@ -165,16 +183,22 @@ function Switch-Shortcut([switch]$KeepCopy) {
@(Get-Content -LiteralPath $PROFILE) | Where-Object { $_ -notmatch "^function $name " } | Set-Content -LiteralPath $PROFILE
}
if ($on) {
if (-not $KeepCopy) { Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue }
if (-not $KeepCopy) {
# Kept in memory so a failed download on the next "on" can restore it
if (Test-Path -LiteralPath $copy) { $script:ShortcutKept = [IO.File]::ReadAllBytes($copy) }
Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue
}
Say " Shortcut removed." 'Green'
return
}
New-Item -ItemType Directory -Path (Split-Path -Path $copy -Parent) -Force | Out-Null
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
if ($PSCommandPath -ne $copy) { Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force }
} else {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "${ScriptUrl}?$(Get-Random)" -OutFile $copy -UseBasicParsing
$stale = $false
if ($PSCommandPath -and ($PSCommandPath -ne $copy) -and (Test-Path -LiteralPath $PSCommandPath)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force
} elseif (-not (Save-ShortcutCopy $copy)) {
if ($script:ShortcutKept -and -not (Test-Path -LiteralPath $copy)) { [IO.File]::WriteAllBytes($copy, $script:ShortcutKept) }
if (-not (Test-Path -LiteralPath $copy)) { throw 'the download failed. Check the connection and try again.' }
$stale = $true
}
Unblock-File -LiteralPath $copy -ErrorAction SilentlyContinue
if ((Get-ExecutionPolicy -Scope CurrentUser) -in 'Undefined', 'Restricted', 'AllSigned') {
Expand All @@ -183,6 +207,7 @@ function Switch-Shortcut([switch]$KeepCopy) {
if (-not (Test-Path -LiteralPath $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE "`n$(Get-ShortcutLine)"
Say " Shortcut added. In a new PowerShell window, just type: $name" 'Green'
if ($stale) { Say " Could not download the latest version; kept the previous copy." 'Yellow' }
} catch {
Say " Could not change the shortcut: $($_.Exception.Message)" 'Red'
}
Expand Down
37 changes: 31 additions & 6 deletions apps/systeminfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,24 @@ function Test-Shortcut {
(Test-Path -LiteralPath $PROFILE) -and (Test-Path -LiteralPath (Get-ShortcutCopy)) -and
(@(Get-Content -LiteralPath $PROFILE -ErrorAction SilentlyContinue) -contains (Get-ShortcutLine))
}
# Downloads the latest script over the local copy; the copy is only replaced by a complete download
function Save-ShortcutCopy($copy) {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$tmp = "$copy.new"
$raw = $ScriptUrl -replace '^https://github\.com/([^/]+/[^/]+)/raw/', 'https://raw.githubusercontent.com/$1/'
foreach ($url in $ScriptUrl, $raw, $ScriptUrl) {
try {
Invoke-WebRequest -Uri "${url}?$(Get-Random)" -OutFile $tmp -UseBasicParsing -ErrorAction Stop
if (Select-String -LiteralPath $tmp -SimpleMatch '$ScriptUrl' -Quiet) {
Move-Item -LiteralPath $tmp -Destination $copy -Force
return $true
}
} catch {}
Start-Sleep -Seconds 2
}
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
return $false
}
function Switch-Shortcut([switch]$KeepCopy) {
$name = Get-ShortcutName
$copy = Get-ShortcutCopy
Expand All @@ -1657,16 +1675,22 @@ function Switch-Shortcut([switch]$KeepCopy) {
@(Get-Content -LiteralPath $PROFILE) | Where-Object { $_ -notmatch "^function $name " } | Set-Content -LiteralPath $PROFILE
}
if ($on) {
if (-not $KeepCopy) { Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue }
if (-not $KeepCopy) {
# Kept in memory so a failed download on the next "on" can restore it
if (Test-Path -LiteralPath $copy) { $script:ShortcutKept = [IO.File]::ReadAllBytes($copy) }
Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue
}
Say " Shortcut removed." 'Green'
return
}
New-Item -ItemType Directory -Path (Split-Path -Path $copy -Parent) -Force | Out-Null
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
if ($PSCommandPath -ne $copy) { Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force }
} else {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "${ScriptUrl}?$(Get-Random)" -OutFile $copy -UseBasicParsing
$stale = $false
if ($PSCommandPath -and ($PSCommandPath -ne $copy) -and (Test-Path -LiteralPath $PSCommandPath)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force
} elseif (-not (Save-ShortcutCopy $copy)) {
if ($script:ShortcutKept -and -not (Test-Path -LiteralPath $copy)) { [IO.File]::WriteAllBytes($copy, $script:ShortcutKept) }
if (-not (Test-Path -LiteralPath $copy)) { throw 'the download failed. Check the connection and try again.' }
$stale = $true
}
Unblock-File -LiteralPath $copy -ErrorAction SilentlyContinue
if ((Get-ExecutionPolicy -Scope CurrentUser) -in 'Undefined', 'Restricted', 'AllSigned') {
Expand All @@ -1675,6 +1699,7 @@ function Switch-Shortcut([switch]$KeepCopy) {
if (-not (Test-Path -LiteralPath $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE "`n$(Get-ShortcutLine)"
Say " Shortcut added. In a new PowerShell window, just type: $name" 'Green'
if ($stale) { Say " Could not download the latest version; kept the previous copy." 'Yellow' }
} catch {
Say " Could not change the shortcut: $($_.Exception.Message)" 'Red'
}
Expand Down
37 changes: 31 additions & 6 deletions apps/zipper.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,24 @@ function Test-Shortcut {
(Test-Path -LiteralPath $PROFILE) -and (Test-Path -LiteralPath (Get-ShortcutCopy)) -and
(@(Get-Content -LiteralPath $PROFILE -ErrorAction SilentlyContinue) -contains (Get-ShortcutLine))
}
# Downloads the latest script over the local copy; the copy is only replaced by a complete download
function Save-ShortcutCopy($copy) {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
$tmp = "$copy.new"
$raw = $ScriptUrl -replace '^https://github\.com/([^/]+/[^/]+)/raw/', 'https://raw.githubusercontent.com/$1/'
foreach ($url in $ScriptUrl, $raw, $ScriptUrl) {
try {
Invoke-WebRequest -Uri "${url}?$(Get-Random)" -OutFile $tmp -UseBasicParsing -ErrorAction Stop
if (Select-String -LiteralPath $tmp -SimpleMatch '$ScriptUrl' -Quiet) {
Move-Item -LiteralPath $tmp -Destination $copy -Force
return $true
}
} catch {}
Start-Sleep -Seconds 2
}
Remove-Item -LiteralPath $tmp -Force -ErrorAction SilentlyContinue
return $false
}
function Switch-Shortcut([switch]$KeepCopy) {
$name = Get-ShortcutName
$copy = Get-ShortcutCopy
Expand All @@ -264,16 +282,22 @@ function Switch-Shortcut([switch]$KeepCopy) {
@(Get-Content -LiteralPath $PROFILE) | Where-Object { $_ -notmatch "^function $name " } | Set-Content -LiteralPath $PROFILE
}
if ($on) {
if (-not $KeepCopy) { Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue }
if (-not $KeepCopy) {
# Kept in memory so a failed download on the next "on" can restore it
if (Test-Path -LiteralPath $copy) { $script:ShortcutKept = [IO.File]::ReadAllBytes($copy) }
Remove-Item -LiteralPath $copy -Force -ErrorAction SilentlyContinue
}
Say " Shortcut removed." 'Green'
return
}
New-Item -ItemType Directory -Path (Split-Path -Path $copy -Parent) -Force | Out-Null
if ($PSCommandPath -and (Test-Path -LiteralPath $PSCommandPath)) {
if ($PSCommandPath -ne $copy) { Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force }
} else {
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -Uri "${ScriptUrl}?$(Get-Random)" -OutFile $copy -UseBasicParsing
$stale = $false
if ($PSCommandPath -and ($PSCommandPath -ne $copy) -and (Test-Path -LiteralPath $PSCommandPath)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $copy -Force
} elseif (-not (Save-ShortcutCopy $copy)) {
if ($script:ShortcutKept -and -not (Test-Path -LiteralPath $copy)) { [IO.File]::WriteAllBytes($copy, $script:ShortcutKept) }
if (-not (Test-Path -LiteralPath $copy)) { throw 'the download failed. Check the connection and try again.' }
$stale = $true
}
Unblock-File -LiteralPath $copy -ErrorAction SilentlyContinue
if ((Get-ExecutionPolicy -Scope CurrentUser) -in 'Undefined', 'Restricted', 'AllSigned') {
Expand All @@ -282,6 +306,7 @@ function Switch-Shortcut([switch]$KeepCopy) {
if (-not (Test-Path -LiteralPath $PROFILE)) { New-Item -ItemType File -Path $PROFILE -Force | Out-Null }
Add-Content -LiteralPath $PROFILE "`n$(Get-ShortcutLine)"
Say " Shortcut added. In a new PowerShell window, just type: $name" 'Green'
if ($stale) { Say " Could not download the latest version; kept the previous copy." 'Yellow' }
} catch {
Say " Could not change the shortcut: $($_.Exception.Message)" 'Red'
}
Expand Down
Loading
Loading