Skip to content

Conversation

@jmcombs
Copy link
Owner

@jmcombs jmcombs commented Jan 18, 2026

Summary

This PR addresses the Oh My Posh integration feature requests and fixes a critical bug in the .NET version script that was causing Docker builds to fail.

Fixes #3 - Feature Request: Enhanced PowerShell Prompt with Oh My Posh Integration
Fixes #4 - Feature Request: Enhanced PowerShell Prompt with Oh My Posh Integration


🐛 Bug Fix: .NET Version Script

Root Cause

The scripts/get-net-pwsh-versions.sh script was failing because Microsoft now has TWO active LTS .NET releases:

Version Support Phase Release Type Latest Runtime
.NET 10.0 active LTS 10.0.1
.NET 8.0 active LTS 8.0.23

The script's jq query returned both results as a multi-line string, causing:

  • latest_runtime = 10.0.1\n8.0.23 (multi-line)
  • releases_json = URL1\nURL2 (multi-line)
  • curl "$releases_json" fails with invalid URL
  • All NET_RUNTIME_URL_* variables remain empty
  • Docker build fails with "curl: (2) no URL specified"

Fix

Added first() to jq queries to select only the newest LTS release:

# Before (returns multiple results)
latest_runtime=$(echo "$response" | jq -r '.[] | select(...) | ...')

# After (returns only first/newest result)
latest_runtime=$(echo "$response" | jq -r 'first(.[] | select(...)) | ...')

✨ Oh My Posh Enhancements

1. Embedded Blue PSL 10K Theme

  • File: config/ohmyposh-container.json
  • Custom theme based on Catppuccin Latte color palette
  • Signature path_blue (#3465a4) color scheme
  • Works offline without internet connection
  • Two-line prompt with box-drawing characters
  • Git integration with dynamic background colors

2. Runtime Environment Variables

  • ENABLE_OHMYPOSH (default: true) - Disable Oh My Posh at runtime
  • OHMYPOSH_THEME (default: empty) - Select custom themes
# Default - Blue PSL 10K theme (works offline)
docker run -it jmcombs/powershell

# Disable Oh My Posh entirely
docker run -it -e ENABLE_OHMYPOSH=false jmcombs/powershell

# Use built-in Oh My Posh theme
docker run -it -e OHMYPOSH_THEME=atomic jmcombs/powershell

# Use custom theme from URL
docker run -it -e OHMYPOSH_THEME=https://example.com/theme.omp.json jmcombs/powershell

3. Three-Tier Fallback Hierarchy

  • Custom theme (from OHMYPOSH_THEME) → Blue PSL 10K (embedded) → Basic PowerShell prompt
  • Prevents broken prompts if theme loading fails

4. Container Optimization

  • Removed unused Nerd Font installation (~150MB savings)
  • Fonts must be installed on HOST machine, not in container
  • Fixed useradd shell from /bin/zsh to /bin/bash

5. Documentation Updates

  • Added comprehensive host font configuration instructions
  • Documented environment variables with usage examples
  • Added theme fallback behavior explanation
  • Added GitHub Sponsors badge

📋 Files Changed

File Changes
scripts/get-net-pwsh-versions.sh Fixed jq queries with first()
config/ohmyposh-container.json Replaced with Blue PSL 10K theme
config/Microsoft.PowerShell_profile.ps1 Theme selection logic and fallback
Dockerfile Env vars, removed fonts, fixed shell
README.md Host font docs, env vars, sponsors
scripts/test-ohmyposh-build.sh Updated test script

✅ Testing Results

Version Script

NET_RUNTIME_URL_arm=https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.1/dotnet-runtime-10.0.1-linux-arm.tar.gz
NET_RUNTIME_URL_arm64=https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.1/dotnet-runtime-10.0.1-linux-arm64.tar.gz
NET_RUNTIME_URL_x64=https://builds.dotnet.microsoft.com/dotnet/Runtime/10.0.1/dotnet-runtime-10.0.1-linux-x64.tar.gz

Docker Build

✅ Build completes successfully for linux/arm64

Container Tests

Test Result
Container startup ✅ Pass
Oh My Posh installed ✅ Pass
Theme file exists ✅ Pass
ENABLE_OHMYPOSH default = true ✅ Pass
Profile loads Blue PSL 10K ✅ Pass
ENABLE_OHMYPOSH=false works ✅ Pass
OHMYPOSH_THEME=atomic works ✅ Pass
.NET 10.0.1 runtime installed ✅ Pass

📝 Checklist

  • Script fix tested locally
  • Docker build completes
  • All container tests pass
  • Documentation updated
  • Theme JSON is valid
  • Environment variables work correctly
  • Fallback mechanism tested

Pull Request opened by Augment Code with guidance from the PR author

- Add Oh My Posh installation to Dockerfile
- Install Nerd Fonts (CaskaydiaCove) for enhanced glyphs
- Create custom PowerShell profile with Oh My Posh initialization
- Add container-optimized Oh My Posh theme configuration
- Include Terminal-Icons and PSReadLine module installation
- Add comprehensive documentation for enhanced prompt features
- Create test scripts for validation
- Update README with enhanced prompt feature overview

Addresses feature request #4 for Scott Hanselman-inspired prompt customization
This commit addresses multiple issues:

1. Script Fix (get-net-pwsh-versions.sh):
   - Fixed jq queries to handle multiple active LTS .NET releases
   - Added first() to select only the newest LTS release
   - Resolves Docker build failures when both .NET 10.0 and 8.0 are active LTS

2. Oh My Posh Enhancements:
   - Embedded Blue PSL 10K theme in container (works offline)
   - Added runtime environment variables:
     * ENABLE_OHMYPOSH (default: true) - disable Oh My Posh at runtime
     * OHMYPOSH_THEME - select built-in or custom themes
   - Implemented three-tier fallback: custom → Blue PSL 10K → basic prompt
   - Theme selection supports URLs, built-in names, and file paths

3. Container Optimization:
   - Removed unused Nerd Font installation (~150MB savings)
   - Fonts must be installed on HOST machine, not in container
   - Fixed useradd shell from /bin/zsh to /bin/bash

4. Documentation:
   - Added comprehensive host font configuration instructions
   - Documented environment variables with usage examples
   - Added theme fallback behavior explanation
   - Added GitHub Sponsors badge

Fixes #3
Fixes #4
@jmcombs jmcombs force-pushed the feature/oh-my-posh-integration branch from aed99aa to c8836a0 Compare January 18, 2026 01:47
Removed tests for Nerd Font installation since fonts must be installed
on the HOST machine, not in the container. Added tests for the new
ENABLE_OHMYPOSH and OHMYPOSH_THEME environment variables instead.
Changes:
- Consolidated ci.yml and test.yml into single CI/CD Pipeline
- PRs: Build test image locally (no push to Docker Hub)
- Integration tests: Use locally built test image (not from Docker Hub)
- Main branch: Tests must pass before build and publish
- Removed separate test.yml (functionality merged into ci.yml)

Pipeline stages:
1. Script Validation + Unit Tests (parallel)
2. Build Test Image (after stage 1)
3. Integration Tests (using test image artifact)
4. Publish to Docker Hub (main branch only, after all tests pass)
- Use -NoProfile flag for tests that don't need profile functions
- Explicitly load profile for tests that need Show-ContainerInfo/info alias
- Remove tests for Terminal-Icons/PSReadLine (not installed during build)
- Add test for install-modules.sh script existence
- Fix OHMYPOSH_THEME test (variable exists but is empty by default)
- Install Terminal-Icons and PSReadLine modules during build instead of
  creating a manual install script
- Modules are now available immediately when container starts
- Updated integration tests to verify modules are installed
- Removed install-modules.sh script creation from Dockerfile
- Updated PowerShell profile welcome message to remove script reference
The container ENTRYPOINT is already set to 'pwsh', so running:
  docker run ... pwsh -NoProfile -c '...'
was executing: pwsh pwsh -NoProfile -c '...'
which caused PowerShell to try to run a script named 'pwsh'.

Fixed by removing 'pwsh' from all docker run commands since it's
already provided by the ENTRYPOINT.
Added badge showcasing the default Oh My Posh theme included in the container,
using the theme's signature blue color (#3465a4).
@jmcombs jmcombs merged commit 6d21b9c into main Jan 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Enhanced PowerShell Prompt with Oh My Posh Integration Feature Request: Enhanced PowerShell Prompt with Oh My Posh Integration

2 participants