diff --git a/bin/powershell7.5.4/deps.properties b/bin/powershell7.5.4/deps.properties index 97a4498..73311c4 100644 --- a/bin/powershell7.5.4/deps.properties +++ b/bin/powershell7.5.4/deps.properties @@ -1,4 +1,4 @@ -oh_my_posh = https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v29.14.0/posh-windows-amd64.exe +oh_my_posh = https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v29.18.0/posh-windows-amd64.exe oh_my_posh_theme = https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/paradox.omp.json # Cascadia Mono Nerd Font - Nerd Font required for Oh My Posh glyphs/icons in the terminal diff --git a/bin/powershell7.5.4/powershell.bat b/bin/powershell7.5.4/powershell.bat index 8461b0c..05bbb0e 100644 --- a/bin/powershell7.5.4/powershell.bat +++ b/bin/powershell7.5.4/powershell.bat @@ -178,10 +178,10 @@ REM Launch PowerShell with custom profile and parameters REM We use cmd /c start to launch in a new process which reliably picks up registry font settings REM then we exit the current (incorrectly fonted) window. if "%NO_EXIT%"=="1" ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -Command "!PS_COMMAND!" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!" exit ) else ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -Command "!PS_COMMAND!; exit" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!; exit" exit ) popd diff --git a/bin/powershell7.6.0/bearsampp.conf b/bin/powershell7.6.0/bearsampp.conf index f1b41a1..6775501 100644 --- a/bin/powershell7.6.0/bearsampp.conf +++ b/bin/powershell7.6.0/bearsampp.conf @@ -2,7 +2,7 @@ powershellVersion = "7.6.0" powershellExe = "pwsh.exe" powershellLaunchExe = "powershell.bat" powershellConf = "config\Microsoft.PowerShell_profile.ps1" -powershellFont = "Cascadia Mono NF" +powershellFont = "CaskaydiaMono NF" powershellRows = "33" powershellCols = "110" diff --git a/bin/powershell7.6.0/powershell.bat b/bin/powershell7.6.0/powershell.bat index 8461b0c..05bbb0e 100644 --- a/bin/powershell7.6.0/powershell.bat +++ b/bin/powershell7.6.0/powershell.bat @@ -178,10 +178,10 @@ REM Launch PowerShell with custom profile and parameters REM We use cmd /c start to launch in a new process which reliably picks up registry font settings REM then we exit the current (incorrectly fonted) window. if "%NO_EXIT%"=="1" ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -Command "!PS_COMMAND!" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!" exit ) else ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -Command "!PS_COMMAND!; exit" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!; exit" exit ) popd diff --git a/bin/powershell7.6.1/powershell.bat b/bin/powershell7.6.1/powershell.bat index 8461b0c..05bbb0e 100644 --- a/bin/powershell7.6.1/powershell.bat +++ b/bin/powershell7.6.1/powershell.bat @@ -178,10 +178,10 @@ REM Launch PowerShell with custom profile and parameters REM We use cmd /c start to launch in a new process which reliably picks up registry font settings REM then we exit the current (incorrectly fonted) window. if "%NO_EXIT%"=="1" ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -Command "!PS_COMMAND!" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!" exit ) else ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -Command "!PS_COMMAND!; exit" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!; exit" exit ) popd diff --git a/bin/powershell7.6.2/powershell.bat b/bin/powershell7.6.2/powershell.bat index 8461b0c..05bbb0e 100644 --- a/bin/powershell7.6.2/powershell.bat +++ b/bin/powershell7.6.2/powershell.bat @@ -178,10 +178,10 @@ REM Launch PowerShell with custom profile and parameters REM We use cmd /c start to launch in a new process which reliably picks up registry font settings REM then we exit the current (incorrectly fonted) window. if "%NO_EXIT%"=="1" ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -Command "!PS_COMMAND!" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!" exit ) else ( - start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -Command "!PS_COMMAND!; exit" + start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!; exit" exit ) popd diff --git a/bin/powershell7.6.3/bearsampp.conf b/bin/powershell7.6.3/bearsampp.conf new file mode 100644 index 0000000..c334c57 --- /dev/null +++ b/bin/powershell7.6.3/bearsampp.conf @@ -0,0 +1,9 @@ +powershellVersion = "7.6.3" +powershellExe = "pwsh.exe" +powershellLaunchExe = "powershell.bat" +powershellConf = "config\Microsoft.PowerShell_profile.ps1" +powershellFont = "CaskaydiaMono NF" +powershellRows = "33" +powershellCols = "110" + +bundleRelease = "@RELEASE_VERSION@" diff --git a/bin/powershell7.6.3/config/Microsoft.PowerShell_profile.ps1 b/bin/powershell7.6.3/config/Microsoft.PowerShell_profile.ps1 new file mode 100644 index 0000000..ff06c89 --- /dev/null +++ b/bin/powershell7.6.3/config/Microsoft.PowerShell_profile.ps1 @@ -0,0 +1,52 @@ +# Bearsampp PowerShell Profile +# This profile configures PowerShell with enhanced console features +# PowerShell 7+ includes PSReadLine by default for command-line editing + +# Get the shell root directory +$SHELL_ROOT = Split-Path -Parent $PSScriptRoot + +# Set environment variables for Oh My Posh +$env:POSH_ROOT = Join-Path $SHELL_ROOT "vendor\oh-my-posh" + +# Set PowerShell module path to include bundled modules +$env:PSModulePath = (Join-Path $SHELL_ROOT "vendor\modules") + ";" + $env:PSModulePath + +# Configure console to use Nerd Font (Cascadia Mono NF) +# This is required for Oh My Posh icons and glyphs to display correctly +# Note: Font configuration is handled by the launcher (powershell.bat) via registry. + +# Initialize Oh My Posh with theme +$ohMyPoshExe = "$env:POSH_ROOT\posh-windows-amd64.exe" +$ohMyPoshTheme = "$env:POSH_ROOT\themes\paradox.omp.json" + +if (Test-Path $ohMyPoshExe -PathType Leaf) { + & $ohMyPoshExe init pwsh --config $ohMyPoshTheme | Invoke-Expression +} + +# Import Terminal-Icons for colorful file/folder icons +Import-Module Terminal-Icons -ErrorAction SilentlyContinue + +# Set PowerShell options for better experience +if ($PSVersionTable.PSVersion.Major -ge 5) { + # Use a single call to Set-PSReadLineOption for speed if possible (not all options can be combined) + Set-PSReadLineOption -EditMode Windows -HistorySearchCursorMovesToEnd -MaximumHistoryCount 10000 -HistoryNoDuplicates + Set-PSReadLineOption -PredictionSource History -ErrorAction SilentlyContinue + Set-PSReadLineOption -Colors @{ + Command = 'Green' + Parameter = 'Gray' + String = 'DarkCyan' + } + + # Key bindings + Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward + Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward + Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete +} + +# Welcome message +# Only show banner in interactive ConsoleHost and not when running commands +if ($Host.Name -eq "ConsoleHost" -and $ExecutionContext.SessionState.LanguageMode -eq "FullLanguage" -and -not $MyInvocation.BoundParameters.ContainsKey('Command')) { + Write-Host "Bearsampp PowerShell" -ForegroundColor Cyan + Write-Host "Enhanced with PSReadLine, Oh My Posh, and Terminal-Icons" -ForegroundColor Gray + Write-Host "" +} diff --git a/bin/powershell7.6.3/config/README.md b/bin/powershell7.6.3/config/README.md new file mode 100644 index 0000000..95bd458 --- /dev/null +++ b/bin/powershell7.6.3/config/README.md @@ -0,0 +1,67 @@ +# Bearsampp PowerShell Configuration + +## Font Requirement + +This PowerShell module requires a **Nerd Font** to display Oh My Posh icons and glyphs correctly. + +### Required Font +- **Font Name**: Cascadia Mono NF +- **Installation**: Should be installed system-wide via Bearsampp prerequisites + +### Configuring the Font + +#### Windows Terminal (Recommended) +If using Windows Terminal, add this to your `settings.json`: + +```json +{ + "profiles": { + "defaults": { + "font": { + "face": "Cascadia Mono NF", + "size": 10 + } + } + } +} +``` + +#### Windows Console Host (conhost.exe) +1. Right-click the title bar → Properties +2. Go to the Font tab +3. Select "Cascadia Mono NF" from the font list +4. Click OK + +#### PowerShell Console +The font is automatically used if it's set as the default console font in Windows. + +## Files + +- **Microsoft.PowerShell_profile.ps1** - Main PowerShell profile + - Configures PSReadLine (command-line editing) + - Initializes Oh My Posh with paradox theme + - Sets up history and key bindings + - Requires Cascadia Mono NF font for proper icon display + +## Environment Variables + +The profile sets these environment variables: +- `POSH_ROOT` - Path to Oh My Posh installation +- `POSH_THEMES_PATH` - Path to Oh My Posh themes directory + +## Customization + +### Change Oh My Posh Theme +Edit the profile and change the theme file: +```powershell +$ohMyPoshTheme = Join-Path $env:POSH_ROOT "themes\YOUR_THEME.omp.json" +``` + +Available themes are in `vendor/oh-my-posh/themes/` + +### Modify PSReadLine Settings +Edit the `Set-PSReadLineOption` calls in the profile to customize: +- Colors +- Key bindings +- History behavior +- Prediction settings diff --git a/bin/powershell7.6.3/config/register-fonts.ps1 b/bin/powershell7.6.3/config/register-fonts.ps1 new file mode 100644 index 0000000..6b65073 --- /dev/null +++ b/bin/powershell7.6.3/config/register-fonts.ps1 @@ -0,0 +1,137 @@ +Add-Type -AssemblyName System.Drawing + +$fontsSrc = $args[0] +$fontsDest = $args[1] + +if (Test-Path $fontsSrc) { + if (-not (Test-Path $fontsDest)) { + try { + New-Item -ItemType Directory -Path $fontsDest -Force | Out-Null + } catch { + Write-Error "Failed to create fonts destination directory" + } + } + + $fontFiles = @(Get-ChildItem -Path $fontsSrc -Include *.ttf, *.otf -Recurse) + if ($fontFiles.Count -eq 0) { + Write-Warning "No font files found in $fontsSrc" + exit 0 + } + + # Fast Path: If there's only one font file, we can potentially skip expensive collection loading + # if we can determine the name simply. But for Nerd Fonts, the file name != family name often. + + # Explicitly load and extract font names + $fc = New-Object System.Drawing.Text.PrivateFontCollection + foreach ($file in $fontFiles) { + try { + $fc.AddFontFile($file.FullName) + } catch { + Write-Warning ("Failed to load font file: " + $file.FullName) + } + } + + if ($fc.Families.Count -eq 0) { + foreach ($file in $fontFiles) { + try { + $fileBytes = [System.IO.File]::ReadAllBytes($file.FullName) + $handle = [System.Runtime.InteropServices.GCHandle]::Alloc($fileBytes, 'Pinned') + $fc.AddMemoryFont($handle.AddrOfPinnedObject(), $fileBytes.Length) + $handle.Free() + } catch {} + } + } + + if ($fc.Families.Count -eq 0) { + Write-Warning "No font families found in $fontsSrc" + exit 0 + } + + $allNames = @($fc.Families | ForEach-Object { $_.Name } | Select-Object -Unique) + # Prefer Nerd Font Mono (NFM) or Mono variants for console + $detectedName = $allNames | Where-Object { $_ -match "NFM|NF|Mono" } | Select-Object -First 1 + $fallbackName = $allNames | Select-Object -First 1 + + $regPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts" + if (-not (Test-Path $regPath)) { + New-Item -Path "HKCU:\Software\Microsoft\Windows NT\CurrentVersion" -Name "Fonts" -Force | Out-Null + } + + $fontFiles | ForEach-Object { + $fontFile = $_.FullName + $destFile = Join-Path $fontsDest $_.Name + + $fileFc = New-Object System.Drawing.Text.PrivateFontCollection + try { + $fileFc.AddFontFile($fontFile) + $internalName = $fileFc.Families[0].Name + } catch { + $internalName = $null + } + + if ($internalName) { + $regValueName = "$internalName (TrueType)" + $currentRegValue = Get-ItemProperty -Path $regPath -Name $regValueName -ErrorAction SilentlyContinue | Select-Object -ExpandProperty $regValueName -ErrorAction SilentlyContinue + + $needsInstall = $false + if (-not (Test-Path $destFile)) { + $needsInstall = $true + } else { + $srcFileItem = Get-Item $fontFile + $destFileItem = Get-Item $destFile + if ($srcFileItem.Length -ne $destFileItem.Length -or $srcFileItem.LastWriteTime -gt $destFileItem.LastWriteTime) { + $needsInstall = $true + } + } + + if ($null -eq $currentRegValue -or ($currentRegValue -ne $destFile -and $currentRegValue -ne $_.Name)) { + $needsInstall = $true + } + + if ($needsInstall) { + try { + Copy-Item $fontFile $destFile -Force + Set-ItemProperty -Path $regPath -Name $regValueName -Value $destFile -Force + + $signature = @' +[DllImport("gdi32.dll", CharSet = CharSet.Auto)] +public static extern int AddFontResourceEx(string lpszFilename, uint fl, IntPtr res); +'@ + $gdi32 = Add-Type -MemberDefinition $signature -Name "Gdi32" -Namespace "Win32" -PassThru + $gdi32::AddFontResourceEx($destFile, 0, [IntPtr]::Zero) | Out-Null + } catch { + Write-Error "Failed to install font $internalName" + } + } + } + } + + $finalName = if ($detectedName) { $detectedName } else { $fallbackName } + if ($finalName) { + # Ensure the font is also registered in Console\TrueTypeFont + $trueTypeFontKey = "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" + if (-not (Test-Path $trueTypeFontKey)) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console" -Name "TrueTypeFont" -Force | Out-Null + } + Set-ItemProperty -Path $trueTypeFontKey -Name "00" -Value $finalName -Force + + $signature = @' +[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] +public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult); +'@ + try { + $user32 = Add-Type -MemberDefinition $signature -Name "User32" -Namespace "Win32" -PassThru + $HWND_BROADCAST = [IntPtr]0xffff + $WM_SETTINGCHANGE = 0x001A + $SMTO_ABORTIFHUNG = 0x0002 + $result = [IntPtr]::Zero + $user32::SendMessageTimeout($HWND_BROADCAST, $WM_SETTINGCHANGE, [IntPtr]::Zero, "Fonts", $SMTO_ABORTIFHUNG, 1000, [ref]$result) | Out-Null + } catch {} + + Write-Output $finalName + } else { + Write-Warning "No valid fonts detected in $fontsSrc" + } +} else { + Write-Error "Fonts source path does not exist: $fontsSrc" +} diff --git a/bin/powershell7.6.3/deps.properties b/bin/powershell7.6.3/deps.properties new file mode 100644 index 0000000..04b39b1 --- /dev/null +++ b/bin/powershell7.6.3/deps.properties @@ -0,0 +1,16 @@ +oh_my_posh = https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-windows-amd64.exe +oh_my_posh_theme = https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/paradox.omp.json + +# Cascadia Mono Nerd Font - Nerd Font required for Oh My Posh glyphs/icons in the terminal +# font_name - must be the windows system name for the font +oh_my_posh_font_name = "CaskaydiaMono NF" + +# Terminal-Icons - PowerShell module for colorful file/folder icons +# Automatically downloads the latest version from PowerShell Gallery during build +terminal_icons = https://www.powershellgallery.com/api/v2/package/Terminal-Icons + +# PSReadLine - Enhanced command-line editing with syntax highlighting, predictive IntelliSense, and history search +# Provides advanced editing features like multi-line editing, undo/redo, and customizable key bindings +# Automatically updated to the latest version from PowerShell Gallery during build process +# Note: PowerShell 7+ includes PSReadLine by default, but this ensures the latest version with newest features +psreadline = https://www.powershellgallery.com/api/v2/package/PSReadLine diff --git a/bin/powershell7.6.3/powershell.bat b/bin/powershell7.6.3/powershell.bat new file mode 100644 index 0000000..05bbb0e --- /dev/null +++ b/bin/powershell7.6.3/powershell.bat @@ -0,0 +1,190 @@ +@echo off +REM Bearsampp PowerShell Launcher +REM This script launches PowerShell with the custom Bearsampp profile +REM +REM Usage: powershell.bat [--title "Title"] [--startingDirectory "Path"] +REM --title - Optional: Window title +REM --startingDirectory - Optional: Starting directory + +setlocal EnableDelayedExpansion +pushd "%CD%" + +REM Get the directory where this script is located +set "SHELL_ROOT=%~dp0" +set "SHELL_ROOT=%SHELL_ROOT:~0,-1%" + +REM Determine which PowerShell executable to use +if exist "%SHELL_ROOT%\pwsh.exe" ( + set "PS_EXE=%SHELL_ROOT%\pwsh.exe" +) else ( + set "PS_EXE=powershell.exe" +) + +REM Set the custom profile path +set "CUSTOM_PROFILE=%SHELL_ROOT%\config\Microsoft.PowerShell_profile.ps1" + +REM Default values +set "WINDOW_TITLE=Bearsampp PowerShell Console" +set "START_DIR=%CD%" +set "NO_EXIT=1" +set "FONT_NAME=CaskaydiaMono NF" + +REM Check if we are running in a specialized console that doesn't need re-config +if defined BEARSAMPP_SHELL goto skip_registry_config + +REM Check if a valid font is already configured in the registry to save time +reg query "HKCU\Console" /v FaceName >nul 2>&1 +if not errorlevel 1 ( + for /f "tokens=2,*" %%A in ('reg query "HKCU\Console" /v FaceName') do ( + set "CURRENT_FONT=%%B" + echo "!CURRENT_FONT!" | findstr /i "NF Nerd Cascadia Caskaydia JetBrains Meslo" >nul + if not errorlevel 1 ( + set "FONT_NAME=!CURRENT_FONT!" + set "SKIP_FONT_CHECK=1" + ) + ) +) + +REM Parse command line arguments +:parse_args +if "%~1"=="" goto end_parse +if /i "%~1"=="--title" ( + if not "%~2"=="" ( + set "WINDOW_TITLE=%~2" + set "SKIP_FONT_CHECK=" + ) + shift + shift + goto parse_args +) +if /i "%~1"=="--startingDirectory" ( + if not "%~2"=="" set "START_DIR=%~2" + shift + shift + goto parse_args +) +REM If 'exit' or any other non-flag argument is passed, it might be intended for PowerShell +REM We check if it's 'exit' specifically to handle the -NoExit flag +if /i "%~1"=="exit" ( + set "NO_EXIT=0" +) +shift +goto parse_args +:end_parse + +REM Font and registry configuration +if "!SKIP_FONT_CHECK!"=="1" goto skip_font_config + +REM We use a single PowerShell call to handle font discovery and registration for speed +set "FONTS_SRC=" +if exist "%SHELL_ROOT%\vendor\fonts" ( + set "FONTS_SRC=%SHELL_ROOT%\vendor\fonts" +) + +set "FONTS_DEST=%LOCALAPPDATA%\Microsoft\Windows\Fonts" +set "REGISTER_FONTS_PS1=%SHELL_ROOT%\config\register-fonts.ps1" + +REM Fast font discovery and registration +REM This script outputs the FONT_NAME to be used +set "POWERSHELL_SCRIPT=$fontName = '!FONT_NAME!'; if (-not (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -Name '*!FONT_NAME!*' -ErrorAction SilentlyContinue)) { $fallbacks = @('CaskaydiaMono NF', 'CaskaydiaCove NF', 'JetBrainsMono NF', 'MesloLGS NF', 'Cascadia Mono NF'); foreach ($f in $fallbacks) { if (Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts' -Name '*$f*' -ErrorAction SilentlyContinue) { $fontName = $f; break } } }; if ('!FONTS_SRC!' -ne '' -and (Test-Path '!REGISTER_FONTS_PS1!')) { $captured = & '!REGISTER_FONTS_PS1!' '!FONTS_SRC!' '!FONTS_DEST!'; if ($captured -and $captured -notmatch 'WARNING:|ERROR:') { $fontName = $captured } }; $fontName" + +for /f "usebackq delims=" %%F in (`^""!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!POWERSHELL_SCRIPT!"^"`) do ( + set "FONT_NAME=%%~F" +) + +:skip_font_config + +REM Escape single quotes for PowerShell +set "PS_WINDOW_TITLE=!WINDOW_TITLE:'=''!" +set "PS_START_DIR=!START_DIR:'=''!" +set "PS_CUSTOM_PROFILE=!CUSTOM_PROFILE:'=''!" + +REM Configure console font via registry BEFORE launching PowerShell +REM This ensures ALL console windows use !FONT_NAME! font with proper UTF-8 support + +if "!SKIP_FONT_CHECK!"=="1" goto skip_registry_config + +REM Set font for the specific window title being used +if not "!WINDOW_TITLE!"=="" ( + reg add "HKCU\Console\!WINDOW_TITLE!" /v FaceName /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v FontFamily /t REG_DWORD /d 54 /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v FontSize /t REG_DWORD /d 0x00100000 /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v FontWeight /t REG_DWORD /d 400 /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v CodePage /t REG_DWORD /d 65001 /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v ScreenBufferSize /t REG_DWORD /d 0x0bb8006e /f >nul 2>&1 + reg add "HKCU\Console\!WINDOW_TITLE!" /v WindowSize /t REG_DWORD /d 0x001e006e /f >nul 2>&1 + +REM Force current window to use the font by setting title + title !WINDOW_TITLE! + + REM Extra "kick" to force conhost to update + powershell -NoProfile -Command "$Host.UI.RawUI.WindowTitle='Refreshing...'; $Host.UI.RawUI.WindowTitle='!PS_WINDOW_TITLE!'" >nul 2>&1 + + REM Optional: Briefly clear screen to force a redraw in some conhost versions + cls +) + +REM Set default console properties (applies to all new console windows) +reg add "HKCU\Console" /v FaceName /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 +reg add "HKCU\Console" /v FontFamily /t REG_DWORD /d 54 /f >nul 2>&1 +reg add "HKCU\Console" /v FontSize /t REG_DWORD /d 0x00100000 /f >nul 2>&1 +reg add "HKCU\Console" /v FontWeight /t REG_DWORD /d 400 /f >nul 2>&1 +reg add "HKCU\Console" /v CodePage /t REG_DWORD /d 65001 /f >nul 2>&1 + +REM Ensure the font is registered as a valid console font in HKCU and HKLM +REM HKLM is often required for conhost.exe to recognize the font +for /f "tokens=2,*" %%A in ('reg query "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "!FONT_NAME! (TrueType)" 2^>nul') do ( + set "FONT_PATH=%%B" + if not "!FONT_PATH!"=="" reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "!FONT_NAME! (TrueType)" /t REG_SZ /d "!FONT_PATH!" /f >nul 2>&1 +) +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v "000" /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 +reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v "0000" /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 +reg add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v "0" /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 +reg add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v "00" /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 +reg add "HKCU\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Console\TrueTypeFont" /v "000" /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 + +REM Also explicitly set for common Bearsampp titles as a fallback +for %%T in ("Bearsampp PowerShell Console" "MariaDB" "MySQL" "PostgreSQL" "Git" "Python" "Composer" "PEAR" "Perl" "Ruby" "Ghostscript" "ngrok" "Node.js" "Console") do ( + reg add "HKCU\Console\%%~T" /v FaceName /t REG_SZ /d "!FONT_NAME!" /f >nul 2>&1 + reg add "HKCU\Console\%%~T" /v FontFamily /t REG_DWORD /d 54 /f >nul 2>&1 + reg add "HKCU\Console\%%~T" /v FontSize /t REG_DWORD /d 0x00100000 /f >nul 2>&1 + reg add "HKCU\Console\%%~T" /v FontWeight /t REG_DWORD /d 400 /f >nul 2>&1 + reg add "HKCU\Console\%%~T" /v CodePage /t REG_DWORD /d 65001 /f >nul 2>&1 +) + +REM Re-apply title +title !WINDOW_TITLE! + +:skip_registry_config + +REM Set UTF-8 code page for current console +chcp 65001 >nul 2>&1 + +REM Ensure the final window title is set +title !WINDOW_TITLE! + +REM Set marker to skip re-config in sub-shells +set "BEARSAMPP_SHELL=1" + +REM Build the PowerShell command with UTF-8 encoding and title refresh +REM We set the title to a temporary value then back to the target title +REM This forces conhost.exe to re-read registry settings for the target title +set "PS_COMMAND=[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::UTF8; $Host.UI.RawUI.WindowTitle='Refreshing...'; $Host.UI.RawUI.WindowTitle='!PS_WINDOW_TITLE!'; Set-Location -LiteralPath '!PS_START_DIR!'; . '!PS_CUSTOM_PROFILE!'" + +REM Extra attempt to force font refresh in some conhost versions +title !WINDOW_TITLE! + +REM Launch PowerShell with custom profile and parameters +REM We use cmd /c start to launch in a new process which reliably picks up registry font settings +REM then we exit the current (incorrectly fonted) window. +if "%NO_EXIT%"=="1" ( + start "!WINDOW_TITLE!" "!PS_EXE!" -NoExit -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!" + exit +) else ( + start "!WINDOW_TITLE!" "!PS_EXE!" -NoProfile -ExecutionPolicy Bypass -Command "!PS_COMMAND!; exit" + exit +) +popd +goto :eof + +endlocal diff --git a/bin/powershell7.6.3/vendor/fonts/CaskaydiaMonoNerdFont-Regular.ttf b/bin/powershell7.6.3/vendor/fonts/CaskaydiaMonoNerdFont-Regular.ttf new file mode 100644 index 0000000..d8e1c49 Binary files /dev/null and b/bin/powershell7.6.3/vendor/fonts/CaskaydiaMonoNerdFont-Regular.ttf differ diff --git a/build.properties b/build.properties index f046278..6146e28 100644 --- a/build.properties +++ b/build.properties @@ -1,5 +1,5 @@ bundle.name = powershell -bundle.release = 2026.5.31 +bundle.release = 2026.6.25 bundle.type = tools bundle.format = 7z