Skip to content
ConsoleMonster

Shell prompt

One themed prompt for PowerShell, bash, zsh, fish, nushell and cmd, with eight presets, shareable theme files and oh-my-posh import.

The prompt is part of the ConsoleMonster module, so it uses the same themes, glyph tiers and colour handling as everything else it draws. Save it once from PowerShell with Set-ConsolePrompt -Save and cmon draws it in your other shells.

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
    Segments  = @{
        git    = @{ BudgetMilliseconds = 1000 }
        dotnet = @{ BudgetMilliseconds = 1000 }
    }
}
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
    Segments  = @{
        git    = @{ BudgetMilliseconds = 1000 }
        dotnet = @{ BudgetMilliseconds = 1000 }
    }
}
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: Prompt, Set-ConsolePrompt

Start in PowerShell

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

  2. Add these lines to your profile (notepad $PROFILE):

    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.

Eight presets

Show-ConsolePrompt -Preset * draws every preset with sample values, so you can compare them before you choose. Plain, Powerline and Diamond are the three styles. Minimal, Focus, Timeline, Developer and Cloud arrange the segments for a purpose: Developer adds toolchain versions in project folders, and Cloud leads with the active Kubernetes and Azure contexts.

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.

Fonts without Powerline symbols get the same layout from the Basic and ASCII glyph tiers, so the prompt doesn't depend on a patched font.

Your colours

Presets take their colours from the active theme, so Set-ConsoleTheme recolours the prompt along with tables and errors. A segment can also have its own background and foreground.

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.

What it shows

Path, Git, the last command's status and duration, the time, an elevated shell and SSH sessions are built in. Optional segments read .NET, Node, Python, Go and Rust versions from project files, the Kubernetes context, the Azure subscription, the AWS profile, the Google Cloud project and the battery.

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.

Slow segments don't hold up typing. Git and the toolchain checks run in the background with a time budget and a cache; the prompt shows the cached value straight away and repaints once if it changed. Get-ConsolePrompt -Segment lists each segment's last value, how long it took and how old its cache is.

Every shell

cmon draws the same prompt in bash, zsh, fish, nushell and cmd through Clink. It reads the prompt you saved with Set-ConsolePrompt -Save, or a prompt theme file given with --config. Command hints need PowerShell's editor, so other shells don't show them, and transient prompts work only in nushell and Clink.

ShellAdd toLine
bash~/.bashrceval "$(cmon init bash)"
zsh~/.zshrceval "$(cmon init zsh)"
fish~/.config/fish/config.fishcmon init fish | source
nushellrun oncemkdir ($nu.data-dir | path join "vendor/autoload"); cmon init nu | save -f ($nu.data-dir | path join "vendor/autoload/cmon.nu")
cmdrun oncecmon init cmd > "%LOCALAPPDATA%\clink\cmon.lua"

cmon is a Native AOT executable built from ConsoleMonster.Cmon in the repository; release downloads are not published yet. Other shells covers durations, right prompts and time budgets in each shell.

Share a prompt

A prompt theme file is a JSON document with a whole prompt in it, ready to keep with your dotfiles or hand to a team. Export-ConsolePrompt writes one, Show-ConsolePrompt -Path previews it and Set-ConsolePrompt -Path uses it.

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

Coming from oh-my-posh

Import-ConsolePrompt reads an oh-my-posh JSON theme and writes it as a prompt theme file. Segments with an equivalent keep their side, order, colours and options, and Notes lists everything left out or approximated.

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

Next