diff --git a/extras/powershell_greeting/README.md b/extras/powershell_greeting/README.md index 81ac0e9..27af769 100644 --- a/extras/powershell_greeting/README.md +++ b/extras/powershell_greeting/README.md @@ -46,9 +46,13 @@ Non-interactive / re-install: Test it manually any time with: ```powershell -Show-J621Greeting +greeting ``` +The profile block also installs a `greeting` helper that (re)sources +`J621Greeting.ps1` and runs `Show-J621Greeting`, so it works even when the +automatic interactive greeting was skipped. + Requirements: `fastfetch` and `curl.exe` (ships with Windows 10 1803+). Image logos need Windows Terminal 1.22+ (sixel) or WezTerm with kitty graphics enabled; other terminals fall back to a plain fastfetch. diff --git a/extras/powershell_greeting/install.ps1 b/extras/powershell_greeting/install.ps1 index 51ac1f4..07a2aba 100644 --- a/extras/powershell_greeting/install.ps1 +++ b/extras/powershell_greeting/install.ps1 @@ -39,6 +39,9 @@ function Get-InstalledConfigValue { param([string]$Name) if (-not (Test-Path -LiteralPath $configFile)) { return $null } $content = Get-Content -LiteralPath $configFile -Raw + # Ignore commented-out lines: the config ships an example token line, and + # matching it would make us probe with the placeholder as a real token. + $content = (@($content -split "`r?`n") | Where-Object { $_ -notmatch '^\s*#' }) -join "`n" $rx = '\$env:' + $Name + ' = ''([^'']*)''' if ($content -match $rx) { return $Matches[1] } return $null @@ -142,8 +145,13 @@ if (-not $NoProfilePatch) { $markerBegin, '# Random J621 library image as the fastfetch logo (extras/powershell_greeting).', '$j621GreetingScript = "$env:APPDATA\j621Greeting\J621Greeting.ps1"', + 'if (Test-Path -LiteralPath $j621GreetingScript) { . $j621GreetingScript }', + '# Run it again any time with: greeting', + 'function greeting {', + ' if (-not (Get-Command Show-J621Greeting -ErrorAction Ignore) -and (Test-Path -LiteralPath $j621GreetingScript)) { . $j621GreetingScript }', + ' Show-J621Greeting', + '}', 'if ((Test-Path -LiteralPath $j621GreetingScript) -and [Environment]::UserInteractive -and -not [Console]::IsOutputRedirected) {', - ' . $j621GreetingScript', ' Show-J621Greeting', '}', $markerEnd