-
-
Notifications
You must be signed in to change notification settings - Fork 0
Add PowerShell 7.6.0 with enhanced console configuration and UTF-8 support #7
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
Merged
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| powershellVersion = "7.6.0" | ||
| powershellExe = "pwsh.exe" | ||
| powershellLaunchExe = "powershell.bat" | ||
| powershellConf = "config\Microsoft.PowerShell_profile.ps1" | ||
| powershellFont = "CaskaydiaCove NF" | ||
| powershellRows = "33" | ||
| powershellCols = "110" | ||
|
|
||
| bundleRelease = "@RELEASE_VERSION@" |
85 changes: 85 additions & 0 deletions
85
bin/powershell7.6.0/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,85 @@ | ||
| # 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 (CaskaydiaCove NF) | ||
| # This is required for Oh My Posh icons and glyphs to display correctly | ||
| try { | ||
| # Attempt to set console font programmatically | ||
| $setFontScript = Join-Path $PSScriptRoot "Set-ConsoleFont.ps1" | ||
| if (Test-Path $setFontScript) { | ||
| & $setFontScript -FontName "CaskaydiaCove NF" -FontSize 16 -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| # Only set default title if one hasn't been set already | ||
| # This allows the launcher to set custom titles per console type | ||
| if ($Host.UI.RawUI.WindowTitle -eq "Administrator: C:\WINDOWS\system32\cmd.exe" -or | ||
| $Host.UI.RawUI.WindowTitle -eq "C:\WINDOWS\system32\cmd.exe" -or | ||
| $Host.UI.RawUI.WindowTitle -match "pwsh\.exe") { | ||
| $Host.UI.RawUI.WindowTitle = "Bearsampp PowerShell Console" | ||
| } | ||
|
|
||
| # Note: Font configuration is typically set in Windows Terminal settings.json | ||
| # or via registry for Windows Console Host. The font should be installed system-wide. | ||
| # Oh My Posh will automatically use the console's configured font. | ||
|
|
||
| # Set POSH_THEMES_PATH for easy theme switching | ||
| $env:POSH_THEMES_PATH = Join-Path $env:POSH_ROOT "themes" | ||
| } catch { | ||
| # Silently continue if console configuration fails | ||
| } | ||
|
|
||
| # Initialize Oh My Posh with theme | ||
| $ohMyPoshExe = Join-Path $env:POSH_ROOT "posh-windows-amd64.exe" | ||
| $ohMyPoshTheme = Join-Path $env:POSH_ROOT "themes\paradox.omp.json" | ||
|
|
||
| if (Test-Path $ohMyPoshExe) { | ||
| if (Test-Path $ohMyPoshTheme) { | ||
| # Initialize Oh My Posh with the paradox theme | ||
| & $ohMyPoshExe init pwsh --config $ohMyPoshTheme | Invoke-Expression | ||
| } else { | ||
| Write-Host "Oh My Posh theme not found: $ohMyPoshTheme" -ForegroundColor Yellow | ||
| } | ||
| } else { | ||
| Write-Host "Oh My Posh not found: $ohMyPoshExe" -ForegroundColor Yellow | ||
| } | ||
|
|
||
| # Import Terminal-Icons for colorful file/folder icons | ||
| try { | ||
| Import-Module Terminal-Icons -ErrorAction SilentlyContinue | ||
| } catch { | ||
| # Silently continue if Terminal-Icons is not available | ||
| } | ||
|
|
||
| # Set PowerShell options for better experience | ||
| Set-PSReadLineOption -EditMode Windows | ||
| Set-PSReadLineOption -PredictionSource History | ||
| Set-PSReadLineOption -HistorySearchCursorMovesToEnd | ||
| Set-PSReadLineOption -Colors @{ | ||
| Command = 'Green' | ||
| Parameter = 'Gray' | ||
| String = 'DarkCyan' | ||
| } | ||
|
|
||
| # Set history options | ||
| Set-PSReadLineOption -MaximumHistoryCount 10000 | ||
| Set-PSReadLineOption -HistoryNoDuplicates | ||
|
|
||
| # Key bindings for better navigation | ||
| Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward | ||
| Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward | ||
| Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete | ||
|
|
||
| # Welcome message | ||
| 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**: CaskaydiaCove NF (Cascadia Code Nerd Font) | ||
| - **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": "CaskaydiaCove NF", | ||
| "size": 10 | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### Windows Console Host (conhost.exe) | ||
| 1. Right-click the title bar → Properties | ||
| 2. Go to the Font tab | ||
| 3. Select "CaskaydiaCove 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 CaskaydiaCove 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,12 @@ | ||
| 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 | ||
|
|
||
| # 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 |
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,79 @@ | ||
| @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 | ||
|
|
||
| REM Get the directory where this script is located | ||
| set "SHELL_ROOT=%~dp0" | ||
| set "SHELL_ROOT=%SHELL_ROOT:~0,-1%" | ||
|
|
||
| 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%" | ||
|
|
||
| REM Parse command line arguments | ||
| :parse_args | ||
| if "%~1"=="" goto end_parse | ||
| if /i "%~1"=="--title" ( | ||
| set "WINDOW_TITLE=%~2" | ||
| shift | ||
| shift | ||
| goto parse_args | ||
| ) | ||
| if /i "%~1"=="--startingDirectory" ( | ||
| set "START_DIR=%~2" | ||
| shift | ||
| shift | ||
| goto parse_args | ||
| ) | ||
| shift | ||
| goto parse_args | ||
| :end_parse | ||
|
|
||
| REM Configure console font via registry BEFORE launching PowerShell | ||
| REM This ensures ALL console windows use CaskaydiaCove NF font with proper UTF-8 support | ||
|
|
||
| REM Set default console properties (applies to all new console windows) | ||
| reg add "HKCU\Console" /v FaceName /t REG_SZ /d "CaskaydiaCove NF" /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 Set font for the specific window title being used | ||
| REM Windows Console Host stores settings per window title | ||
| if not "!WINDOW_TITLE!"=="" ( | ||
| reg add "HKCU\Console\!WINDOW_TITLE!" /v FaceName /t REG_SZ /d "CaskaydiaCove NF" /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 | ||
| ) | ||
|
|
||
| REM Also set for common Bearsampp console titles to ensure consistency | ||
| for %%T in ("Bearsampp PowerShell Console" "MariaDB" "MySQL" "PostgreSQL" "Git" "Python" "Composer" "PEAR" "Perl" "Ruby" "Ghostscript" "ngrok" "Node.js") do ( | ||
| reg add "HKCU\Console\%%~T" /v FaceName /t REG_SZ /d "CaskaydiaCove NF" /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 Set UTF-8 code page for current console | ||
| chcp 65001 >nul 2>&1 | ||
|
|
||
| REM Build the PowerShell command with UTF-8 encoding | ||
| set "PS_COMMAND=[Console]::OutputEncoding = [System.Text.Encoding]::UTF8; [Console]::InputEncoding = [System.Text.Encoding]::UTF8; $Host.UI.RawUI.WindowTitle='!WINDOW_TITLE!'; Set-Location '!START_DIR!'; . '!CUSTOM_PROFILE!'" | ||
|
|
||
| REM Launch PowerShell with custom profile and parameters | ||
| "%SHELL_ROOT%\pwsh.exe" -NoExit -NoProfile -Command "!PS_COMMAND!" | ||
|
|
||
| endlocal | ||
Binary file not shown.
78 changes: 78 additions & 0 deletions
78
bin/powershell7.6.0/vendor/oh-my-posh/themes/paradox.omp.json
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,78 @@ | ||
| { | ||
| "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | ||
| "blocks": [ | ||
| { | ||
| "alignment": "left", | ||
| "segments": [ | ||
| { | ||
| "background": "#ffe9aa", | ||
| "foreground": "#100e23", | ||
| "powerline_symbol": "\ue0b0", | ||
| "style": "powerline", | ||
| "template": " \uf0e7 ", | ||
| "type": "root" | ||
| }, | ||
| { | ||
| "background": "#ffffff", | ||
| "foreground": "#100e23", | ||
| "powerline_symbol": "\ue0b0", | ||
| "style": "powerline", | ||
| "template": " {{ .UserName }}@{{ .HostName }} ", | ||
| "type": "session" | ||
| }, | ||
| { | ||
| "background": "#91ddff", | ||
| "foreground": "#100e23", | ||
| "powerline_symbol": "\ue0b0", | ||
| "properties": { | ||
| "folder_icon": "\uf115", | ||
| "folder_separator_icon": " \ue0b1 ", | ||
| "style": "full" | ||
| }, | ||
| "style": "powerline", | ||
| "template": " {{ .Path }} ", | ||
| "type": "path" | ||
| }, | ||
| { | ||
| "background": "#95ffa4", | ||
| "foreground": "#193549", | ||
| "powerline_symbol": "\ue0b0", | ||
| "style": "powerline", | ||
| "template": " {{ .HEAD }} ", | ||
| "type": "git" | ||
| }, | ||
| { | ||
| "background": "#906cff", | ||
| "foreground": "#100e23", | ||
| "powerline_symbol": "\ue0b0", | ||
| "style": "powerline", | ||
| "template": " \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ", | ||
| "type": "python" | ||
| }, | ||
| { | ||
| "background": "#ff8080", | ||
| "foreground": "#ffffff", | ||
| "powerline_symbol": "\ue0b0", | ||
| "style": "powerline", | ||
| "template": " \ue20f ", | ||
| "type": "status" | ||
| } | ||
| ], | ||
| "type": "prompt" | ||
| }, | ||
| { | ||
| "alignment": "left", | ||
| "newline": true, | ||
| "segments": [ | ||
| { | ||
| "foreground": "#007ACC", | ||
| "style": "plain", | ||
| "template": "\u276f ", | ||
| "type": "text" | ||
| } | ||
| ], | ||
| "type": "prompt" | ||
| } | ||
| ], | ||
| "version": 3 | ||
| } |
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
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. Powershell command injection
🐞 Bug⛨ SecurityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools