🚀 Streaming Prompt Rendering (Beta)
Oh My Posh now supports streaming mode - a new rendering approach that displays your prompt progressively as segments complete, instead of waiting for all segments to finish before showing anything.
What's New
- Instant prompt display: Get an immediate prompt with fast segments, while slow segments load in the background
- Progressive updates: The prompt updates incrementally as data-fetching segments (APIs, git status, etc.) complete
- Configurable timeout: Set the segment timeout threshold via the
streamingconfig property (recommended: 100ms) - Pending placeholders: Segments still loading show
...by default (customizable via segmentplaceholderproperty) - Multi-shell support: Available in PowerShell 7.2+, Zsh, and Fish
Configuration
Enable streaming by adding a timeout value (in milliseconds) to your config:
{
"streaming": 100,
"blocks": [...]
}How It Works
sequenceDiagram
participant Shell
participant CLI as oh-my-posh stream
participant Engine
participant Segments as Segment Workers
Shell->>CLI: Execute with context
CLI->>Engine: Initialize streaming
par Concurrent Execution
Engine->>Segments: Start all segments
Segments-->>Engine: Fast segments complete
Segments-->>Engine: Slow segments timeout
end
Engine->>CLI: Render initial prompt<br/>(fast segments + "..." placeholders)
CLI->>Shell: Output prompt (null-delimited)
Shell->>Shell: Display initial prompt
loop Background completion
Segments-->>Engine: Slow segment completes
Engine->>Engine: Re-render prompt with new data
Engine->>CLI: Output updated prompt
CLI->>Shell: Send update (null-delimited)
Shell->>Shell: Redraw prompt progressively
end
Segments->>Engine: All segments complete
Engine->>CLI: Final prompt
CLI->>Shell: Close stream
Technical Details
- New
oh-my-posh streamcommand outputs null-byte delimited prompts (\0) for proper multi-line handling - Segments that exceed the timeout threshold are marked as
Pendingand continue executing in goroutines - Background segments notify the engine via channels when they complete
- The entire prompt is re-rendered incrementally (not just the changed segment)
- Shell integration scripts handle async updates using:
- PowerShell: Event-based
DataAddedwithPSConsoleReadLine::InvokePrompt() - Zsh: File descriptor with
zle -Fasync handler andzle reset-prompt - Fish: Background process with
SIGUSR1signal andcommandline --function repaint
- PowerShell: Event-based
Benefits
- Improved responsiveness: No more waiting for slow API calls or network operations
- Better UX: See your prompt immediately, with updates appearing as they're ready
- Flexible configuration: Set timeouts per your needs and customize pending indicators
Notes
⚠️ This is an experimental beta feature. The behavior and configuration may evolve in future releases.
For more information, see the streaming documentation.