Skip to content
ConsoleMonster

Shell prompt

A themed PowerShell prompt with eight presets, shareable prompt theme files, Git and toolchain segments, transient prompts and hints as you type.

Configure the prompt, then enable it for the current PowerShell session.

Set-ConsolePrompt -Preset Powerline -Left admin,session,path,git -Right status,duration,time
Enable-ConsoleFormatting -Include Prompt

Use Show-ConsolePrompt -Preset * to preview the eight presets (Plain, Powerline, Diamond, Minimal, Focus, Timeline, Developer, and Cloud), each under its name, or add -AsWidget to export the preview. Omit -Preset to preview your current configuration, including its optional segments. Previews use sample values. Use Get-ConsolePrompt to inspect the effective configuration and Get-ConsolePrompt -Segment to see the last values, timings, and cache ages. After a command, the prompt shows each cached value normally while the provider checks it, and repaints once if the value changed. A value uses the muted theme role only when no fresh answer is available: the check failed or missed its time budget, or the value outlived its cache lifetime without a check in progress.

Add -Save to Set-ConsolePrompt to store the configuration in the settings file's Prompt section. Enable-ConsoleFormatting -Save still remembers which formatting features to install. If an older settings file contains Formatting.PromptLayout or Formatting.PromptSegments, the prompt warns and points to Set-ConsolePrompt -Save. Disable-ConsoleFormatting -Feature Prompt restores the previous PowerShell prompt and editor settings.

The compact layout keeps the input on the prompt line. Terminals without VT cursor control place both segment lists before the input marker. TwoLine reserves a separate input line. As the terminal narrows, right segments give way first, followed by lower-priority left segments and path shortening. Select Full glyphs only when your font includes Powerline symbols. The Basic tier draws Powerline separators and Diamond caps with half-block characters, and the ASCII tier falls back to Plain spacing.

Individual segment settings live in the Segments hashtable.

$segments = @{
    path     = @{ Style = 'Agnoster'; MaxWidth = 40 }
    duration = @{ Threshold = '00:00:02' }
    time     = @{ Format = 'HH:mm' }
    git      = @{ Counts = $true; Stash = $true }
}
Set-ConsolePrompt -Segments $segments -Transient time -Hints

Path styles include Full, Folder, Agnoster, and Unique. Unique uses cached directory information to distinguish sibling names. Duration reports only times above the threshold. Give the threshold in whole seconds or as a time span such as 00:00:02. Git refreshes asynchronously and can show tracking, working tree changes, stash count, and in-progress operations. An idle prompt waits 75 ms after the first background result to combine nearby updates into one repaint. It keeps the original display while input is being edited. Later results appear at the next prompt.

The shell prompt in a Git repository

A two-line Powerline prompt in a small repository: the branch and its change count, a hint while dotnet is typed, a slow command's duration and a failed command's exit code. After Enter, each earlier prompt keeps only its status.

Set-ConsolePrompt 100×1824-bitFull
PowerShellprompt.ps1View on GitHub
# A two-line Powerline prompt: the folder and Git on the left, the last command's result and duration on the right.
# After Enter, the prompt left in scrollback keeps only its status. Typing a tool's name shows that tool's segment.
$prompt = @{
    Preset    = 'Powerline'
    Left      = 'path', 'git'
    Right     = 'status', 'duration'
    Transient = 'status'
    Hints     = $true
}
Set-ConsolePrompt @prompt
Enable-ConsoleFormatting -Include Prompt
Full program
Import-Module ConsoleMonster

# A two-line Powerline prompt: the folder and Git on the left, the last command's result and duration on the right.
# After Enter, the prompt left in scrollback keeps only its status. Typing a tool's name shows that tool's segment.
$prompt = @{
    Preset    = 'Powerline'
    Left      = 'path', 'git'
    Right     = 'status', 'duration'
    Transient = 'status'
    Hints     = $true
}
Set-ConsolePrompt @prompt
Enable-ConsoleFormatting -Include Prompt

Use it in every session

PowerShell 5.1 and 7
Install-Module ConsoleMonster -Scope CurrentUser
# Put the script's lines in your profile (notepad $PROFILE), then open a new window

See also: Shell prompt, Set-ConsolePrompt

Install

  1. Install the module once: Install-Module ConsoleMonster -Scope CurrentUser.

  2. Add these lines to your profile (notepad $PROFILE), choosing the preset and segments you want:

    Import-Module ConsoleMonster
    Set-ConsolePrompt -Preset Powerline -Transient time -Hints
    Enable-ConsoleFormatting -Include Prompt
    
  3. Open a new PowerShell window. Disable-ConsoleFormatting -Feature Prompt puts your previous prompt back.

Presets and styles

Show-ConsolePrompt -Preset * draws every built-in preset with sample values, so you can compare them before you choose. Plain, Powerline and Diamond show the three styles: Plain spaces its segments, Powerline joins solid segments with triangular separators, and Diamond rounds their caps. Minimal keeps only the folder and Git, Focus moves everything about the last command to the far edge, Timeline starts each prompt with the time, Developer adds toolchain versions in project folders, and Cloud leads with the active Kubernetes and Azure contexts and shows AWS and Google Cloud as you type their commands. Fonts without Powerline symbols get the same layout from the Basic and ASCII glyph tiers.

Show-ConsolePrompt -Preset * 100 columns24-bitFull
PowerShellprompt-presets.ps1
# Every built-in preset, drawn with sample values.
Show-ConsolePrompt -Preset * -Width 100
Full program
Import-Module ConsoleMonster

# Every built-in preset, drawn with sample values.
Show-ConsolePrompt -Preset * -Width 100
Show-ConsolePrompt -Preset * in PowerShell 7, 100 columns, Full glyphs.
Show-ConsolePrompt -Preset * 100 columns24-bitBasic
Show-ConsolePrompt -Preset * 100 columns24-bitAscii
The same presets with CONSOLEMONSTER_GLYPHS=basic and ascii, for fonts without Powerline symbols.

Colours

Presets take their colours from the active theme, so Set-ConsoleTheme recolours the prompt along with tables, errors and everything else. A segment can also have its own Background and Foreground, and the input marker can be any short text.

Show-ConsolePrompt -Preset Developer 100 columns24-bitFull
PowerShellprompt-schemes.ps1
# A preset takes its colours from the active theme, so one prompt follows every scheme.
$schemes = 'Dark', 'Catppuccin Mocha', 'Dracula', 'Gruvbox Dark', 'Nord', 'Tokyo Night Dark'
foreach ($scheme in $schemes) {
    Set-ConsoleTheme -Theme $scheme
    Write-Host $scheme
    Show-ConsolePrompt -Preset Developer -Width 100
}
Full program
Import-Module ConsoleMonster

# A preset takes its colours from the active theme, so one prompt follows every scheme.
$schemes = 'Dark', 'Catppuccin Mocha', 'Dracula', 'Gruvbox Dark', 'Nord', 'Tokyo Night Dark'
foreach ($scheme in $schemes) {
    Set-ConsoleTheme -Theme $scheme
    Write-Host $scheme
    Show-ConsolePrompt -Preset Developer -Width 100
}
The Developer preset under six colour schemes.
Show-ConsolePrompt 100 columns24-bitFull
PowerShellprompt-colours.ps1
# Segment colours and the input marker belong to the prompt theme and survive a scheme change.
$segments = @{
    admin = @{ Background = '#e06c75'; Foreground = '#282c34' }
    path  = @{ Background = '#61afef'; Foreground = '#282c34' }
    git   = @{ Background = '#98c379'; Foreground = '#282c34' }
}
Set-ConsolePrompt -Preset Diamond -Segments $segments -Marker '❯'
Show-ConsolePrompt -Width 100
Full program
Import-Module ConsoleMonster

# Segment colours and the input marker belong to the prompt theme and survive a scheme change.
$segments = @{
    admin = @{ Background = '#e06c75'; Foreground = '#282c34' }
    path  = @{ Background = '#61afef'; Foreground = '#282c34' }
    git   = @{ Background = '#98c379'; Foreground = '#282c34' }
}
Set-ConsolePrompt -Preset Diamond -Segments $segments -Marker '❯'
Show-ConsolePrompt -Width 100
A Diamond prompt with its own segment colours and input marker.

Configure segments

Set-ConsolePrompt without -Save changes the current session, and Show-ConsolePrompt without -Preset previews it.

Show-ConsolePrompt 100 columns24-bitFull
PowerShellprompt-segments.ps1
# A compact Powerline prompt with optional toolchain, Kubernetes and battery segments, for this session only.
$prompt = @{
    Style  = 'Powerline'
    Layout = 'Compact'
    Left   = 'path', 'git', 'dotnet'
    Right  = 'status', 'kubectl', 'battery'
}
Set-ConsolePrompt @prompt
Show-ConsolePrompt -Width 100
Full program
Import-Module ConsoleMonster

# A compact Powerline prompt with optional toolchain, Kubernetes and battery segments, for this session only.
$prompt = @{
    Style  = 'Powerline'
    Layout = 'Compact'
    Left   = 'path', 'git', 'dotnet'
    Right  = 'status', 'kubectl', 'battery'
}
Set-ConsolePrompt @prompt
Show-ConsolePrompt -Width 100
A compact Powerline prompt with optional .NET, Kubernetes and battery segments, previewed with sample values.

Colours and marker

Segments take their colours from the active theme, so Set-ConsoleTheme recolours the prompt too. To give a segment its own colours, set Background and Foreground in its options to a theme role such as Accent or Info, or to a colour such as #61afef, orange1 or 208. In Powerline and Diamond styles the background fills the segment. In Plain style the foreground colours the text. A value whose refresh failed keeps the muted role. -Marker sets the input marker, up to eight characters. Terminals and glyph tiers that cannot draw it show >.

$segments = @{
    path = @{ Background = '#61afef'; Foreground = '#282c34' }
    git  = @{ Background = '#98c379'; Foreground = '#282c34' }
}
Set-ConsolePrompt -Preset Diamond -Segments $segments -Marker '❯'

Prompt theme files

A prompt theme file is a JSON document holding a whole prompt configuration, which you can share with a team or keep with your dotfiles. Export-ConsolePrompt writes the current configuration, or a preset with -Preset. Show-ConsolePrompt -Path previews a file, and Set-ConsolePrompt -Path starts from it. Other Set-ConsolePrompt parameters change only what they name.

Export-ConsolePrompt -Path ./team.prompt.json -Description 'Team prompt'
Show-ConsolePrompt -Path ./team.prompt.json
Set-ConsolePrompt -Path ./team.prompt.json -Save

The file has SchemaVersion (1), Name, an optional Description, and the same settings as the settings file's Prompt section: Style, Layout, Marker, Left, Right, Transient, Hints, ShellIntegration and Segments. Keys are case-insensitive. An unknown key, segment, colour or time format is rejected, with the setting it names, before anything changes. An omitted Transient turns transient prompts off.

{
  "SchemaVersion": 1,
  "Name": "Team",
  "Style": "Diamond",
  "Layout": "TwoLine",
  "Marker": "❯",
  "Left": [ "admin", "path", "git" ],
  "Right": [ "status", "duration" ],
  "Transient": [],
  "Segments": { "git": { "Background": "#98c379", "Stash": "true" } }
}

Reading oh-my-posh themes

Import-ConsolePrompt reads an oh-my-posh JSON theme and writes it as a prompt theme file next to it (mytheme.omp.json becomes mytheme.prompt.json). Use -OutFile to choose another destination. The command does not change the session.

$result = Import-ConsolePrompt -Path ./mytheme.omp.json
$result.Notes
Show-ConsolePrompt -Path $result.Path

Segments with a ConsoleMonster equivalent keep their side, order and colours, including palette references. Their options also carry over: the path style, Git counts and stash, the duration threshold, the time format and the status segment's always_enabled. A trailing line that holds only literal text becomes the input marker, a transient prompt keeps the marker, and tooltips become command hints. The most common segment style is used for every segment.

Notes lists everything left out or approximated: segments without an equivalent, text templates (each segment shows its standard text), conditional colours, custom separators, unresolved colours and settings such as the console title. YAML and TOML themes are not read; convert them to JSON first.

Optional segments

Add optional segments to either side. Developer and Cloud already include some of them; the other presets leave them off.

Set-ConsolePrompt -Preset Powerline -Left admin,session,path,git,dotnet -Right status,kubectl,battery -Hints
SegmentSource
dotnet, node, python, go, rustProject files, pins, and the active Python environment. Installed-tool version checks start in the home directory. A .NET SDK or Rust toolchain pin that supplies only a path does not trigger a version check. Project detection stops at the repository root.
kubectlThe active context and namespace from KUBECONFIG or the default kubeconfig.
azureThe active subscription in a loaded Az.Accounts session, a saved Az context, or the Azure CLI profile.
aws, gcloudThe active AWS profile or Google Cloud project from configuration and environment variables.
batterySystem charge and state on Windows, Linux, and macOS, shown while discharging or at or below Threshold (20% by default).

KUBECONFIG, AWS_CONFIG_FILE, and CLOUDSDK_CONFIG accept absolute paths or paths relative to your home directory. The prompt uses an active Azure subscription only when Az.Accounts is already loaded. Otherwise it reads the saved Az or Azure CLI profile.

The Git segment keeps Git’s safe.directory ownership check and disables hooks, fsmonitor, and the clean and process filters it finds in Git’s effective configuration. Git LFS stays on when its clean and process commands are the standard git-lfs clean -- %f and git-lfs filter-process from your global or system configuration, git-lfs is installed, and every PATH entry is an absolute directory, so LFS files are not reported as modified. Any other LFS setup, including one changed by the repository’s own configuration, is switched off like other filters, and LFS files with changed timestamps can then appear modified until git status runs outside the prompt. Filter discovery runs once per repository and again when a Git configuration file in the repository or your home directory changes, or after a minute. Git still reads repository configuration, includes, and attributes. An extracted repository owned by your account can pass the ownership check, and configuration can change between filter discovery and git status. Keep Git disabled in the prompt when working in directories whose repository metadata you do not trust.

Use BudgetMilliseconds or CacheMilliseconds in a segment's option hashtable to change its probe deadline or refresh interval. Contextual hints use the first command word after Space. Compact prompts need VT cursor control to update hints while you type. Set a segment's Commands option to a comma-separated list of patterns to choose when its hint appears.

Editing and terminal integration

An empty transient list keeps only the input marker after Enter. Pass -Transient $null to disable transient prompts. Supported PSReadLine versions chain the existing key handlers. Older editors keep the full prompt and omit contextual hints. Plain and accessible modes keep editing undisturbed. Use -ShellIntegration:$false to disable terminal prompt marks and directory notifications.

For a C# host, create a PromptContext snapshot, pass it with a PromptConfiguration to ShellPrompt, and keep one PromptEngine for the session if you use asynchronous segments. Call engine.Refresh(snapshot, configuration) when the host needs updated values. Measurement, rendering, and exports read available values without scheduling probes. The engine can also receive a collection of IPromptSegment implementations.

Next

  • Everyday formatting: the other features Enable-ConsoleFormatting installs.
  • Themes: the colours the prompt's segments take.
  • Hosts and CI: where terminal features such as shell integration are available.

Edit this page on GitHub