$cv = Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" $env:STARSHIP_CONFIG = "$HOME\Documents\WindowsPowerShell\starship.toml" $env:STARSHIP_CACHE = "$HOME\AppData\Local\Temp" function CenterWindow { Add-Type -AssemblyName System.Windows.Forms Add-Type @" using System; using System.Runtime.InteropServices; public class WinAPI { [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hWnd, out RECT rect); [DllImport("user32.dll")] public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int w, int h, bool repaint); public struct RECT { public int Left, Top, Right, Bottom; } } "@ $hwnd = if ($env:WT_SESSION) { (Get-Process -Name "WindowsTerminal" -ErrorAction SilentlyContinue | Select-Object -First 1).MainWindowHandle } else { (Get-Process -Id $PID).MainWindowHandle } if (-not $hwnd -or $hwnd -eq [IntPtr]::Zero) { return } $screen = [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea $rect = New-Object WinAPI+RECT [WinAPI]::GetWindowRect($hwnd, [ref]$rect) $w = $rect.Right - $rect.Left $h = $rect.Bottom - $rect.Top $x = $screen.Left + ($screen.Width - $w) / 2 $y = $screen.Top + ($screen.Height - $h) / 2 [WinAPI]::MoveWindow($hwnd, [int]$x, [int]$y, $w, $h, $true) | Out-Null } function Get-RandomLine { param ( [string[]]$Lines = @( "good boy <3", "good girl <3", "well done!", "keep going <3" ) ) return $Lines | Get-Random } function printScreen($isWT) { Clear-Host if ($isWT) { $host.UI.RawUI.WindowTitle = "Powershell <3" } #CenterWindow "$($cv.ProductName) $($cv.DisplayVersion) (Build $($cv.CurrentBuild))" Get-RandomLine if ($isWT) { Invoke-Expression (&starship init powershell) } } # Main printScreen $env:WT_SESSION