-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add PowerShell 7.6.3 with enhanced console configuration and Nerd Font support #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
N6REJ
wants to merge
2
commits into
main
Choose a base branch
from
7.6.3
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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@" |
52 changes: 52 additions & 0 deletions
52
bin/powershell7.6.3/config/Microsoft.PowerShell_profile.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 "" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Unpinned dependency downloads
🐞 Bug⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools