Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/powershell7.5.4/deps.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
oh_my_posh = https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-windows-amd64.exe
oh_my_posh = https://github.com/Bearsampp/modules-untouched/releases/download/powershell-2026.3.22/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
Expand Down
9 changes: 9 additions & 0 deletions bin/powershell7.6.0/bearsampp.conf
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 bin/powershell7.6.0/config/Microsoft.PowerShell_profile.ps1
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 ""
67 changes: 67 additions & 0 deletions bin/powershell7.6.0/config/README.md
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
12 changes: 12 additions & 0 deletions bin/powershell7.6.0/deps.properties
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
79 changes: 79 additions & 0 deletions bin/powershell7.6.0/powershell.bat
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!"
Comment on lines +74 to +77

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Powershell command injection 🐞 Bug ⛨ Security

The 7.6.0 launcher builds a PowerShell -Command string by directly embedding user-controlled
--title and --startingDirectory values inside single quotes, enabling quote-breaking and
arbitrary command execution. A crafted argument containing a single quote can escape the string and
run attacker-chosen PowerShell code.
Agent Prompt
### Issue description
`bin/powershell7.6.0/powershell.bat` constructs a PowerShell `-Command` string by embedding user-provided `--title` and `--startingDirectory` values inside single-quoted PowerShell strings. This allows quote-breaking (via `'`) and arbitrary PowerShell command execution.

### Issue Context
The launcher currently does:
- Parse `--title` / `--startingDirectory` into environment variables
- Build `PS_COMMAND=... $Host.UI.RawUI.WindowTitle='...'; Set-Location '...'; . '...profile...'`
- Execute it via `pwsh.exe -Command`.

### Fix Focus Areas
- Replace string-interpolation execution with a dedicated PowerShell launcher script (e.g., `config\launcher.ps1`) invoked via `pwsh.exe -File`, passing title/startDir/profilePath as parameters (no eval).
- If `-Command` must remain, implement strict escaping for single quotes in injected values (replace `'` with `''`) and avoid delayed expansion pitfalls.

- bin/powershell7.6.0/powershell.bat[22-77]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


endlocal
Binary file not shown.
78 changes: 78 additions & 0 deletions bin/powershell7.6.0/vendor/oh-my-posh/themes/paradox.omp.json
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
}
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bundle.name = powershell
bundle.release = 2026.1.5
bundle.release = 2026.3.22
bundle.type = tools
bundle.format = 7z

Expand Down
Loading