A fast, customizable PowerShell prompt written in C# and compiled as a native AOT binary for instant startup.
- Lightning fast: Native AOT compilation means zero startup delay
- Git integration: Shows current branch with smart caching
- Path display: Intelligently truncates long paths to fit terminal width
- Command feedback: Displays exit codes and execution duration
- System info: Shows OS and shell information
- Simple mode: Minimal prompt option for even faster rendering
No build tools or .NET SDK required:
irm https://raw.githubusercontent.com/lucaspimentel/pwsh-prompt/main/install-remote.ps1 | iexOr to install a specific version:
$version = "1.0.0"; irm https://raw.githubusercontent.com/lucaspimentel/pwsh-prompt/main/install-remote.ps1 | iexClone the repository and run the installation script:
./install-local.ps1This will build the native binary and install it to ~/.local/bin/pwsh-prompt.
Add this line to your PowerShell profile ($PROFILE):
Invoke-Expression (& ~/.local/bin/pwsh-prompt init)For a minimal prompt with just path, git, and host information:
# Edit the init output or modify your profile to use --simple
pwsh-prompt prompt --simple# Quick build test
dotnet build src/pwsh-prompt -c Release -f net10.0
# Publish for Windows
dotnet publish src/pwsh-prompt -c Release -r win-x64 --output ./publish
# Publish for Linux
dotnet publish src/pwsh-prompt -c Release -r linux-x64 --output ./publish
# Or build via solution
dotnet build pwsh-prompt.slnxpwsh-prompt/
├── src/
│ └── pwsh-prompt/ # Main C# project
│ ├── Modules/ # Segment implementations (ISegment)
│ ├── Program.cs # Entry point and mode routing
│ ├── Arguments.cs # Command-line argument parsing
│ ├── GitInfo.cs # Git repository detection and caching
│ ├── Init.cs # PowerShell initialization script generator
│ └── ... # Other core files
├── install-local.ps1 # Build from source and install
├── install-remote.ps1 # Download from GitHub releases and install
└── pwsh-prompt.slnx # Solution file
The prompt uses a modular segment system where each visual element (path, git branch, exit code, etc.) implements the ISegment interface. The application runs in two modes:
- init mode: Generates PowerShell initialization code to install the prompt
- prompt mode: Renders the actual prompt on every invocation
Since this runs on every prompt render, performance is critical:
- Native AOT compilation eliminates JIT overhead for instant startup
- Environment variable caching avoids repeated git file I/O (cache invalidates on directory change or
.git/HEADmodification) - Stack-allocated buffers minimize heap allocations via
ValueStringBuilder - Smart truncation calculates exact widths for optimal path display
The PowerShell profile caches git information between prompts, avoiding file system operations when the branch hasn't changed.
MIT License - see LICENSE file for details.
Copyright (c) 2025 Lucas Pimentel