Skip to content
ConsoleMonster
Class

ShellPrompt

ConsoleMonster.Widgets

Namespace
ConsoleMonster.Widgets
Assembly
ConsoleMonster
Implements
IWidget
Modifiers
sealed

A compact shell prompt. The host supplies status, history duration and optional cached git data.

Inheritance

  • object
  • ShellPrompt

Usage

Explore 24 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Accepted by parameters 12

Constructors

public ShellPrompt() #

Methods

public Size Measure(Constraints constraints, RenderContext context) #

Returns the size the widget wants within the constraints.

Parameters

constraints ConsoleMonster.Layout.Constraints required
The space offered.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.

Returns

Size The desired size, never larger than the constraints.
public void Render(Region region, RenderContext context) #

Renders into a region. The region may be smaller or larger than the measured size.

Parameters

region ConsoleMonster.Canvas.Region required
The target region.
context ConsoleMonster.Canvas.RenderContext required
Profile, theme and glyphs.
public string ToAnsi(RenderContext context, int width) #

Returns the prompt as terminal text without writing or changing terminal state.

Parameters

context ConsoleMonster.Canvas.RenderContext required
The active theme, glyphs and terminal capabilities.
width int required
Available terminal cells, including a trailing input space.

Returns

string One prompt line, with SGR only when colour is supported.

Properties

public string Path { get; set; } #

The current provider path.

public string? Home { get; set; } #

The home directory, abbreviated only at a complete path boundary.

public string? Branch { get; set; } #

The branch name, or a detached commit identifier; null omits git information.

public bool Dirty { get; set; } #

Whether git reported working tree or index changes.

public bool Succeeded { get; set; } #

Whether PowerShell reported the last command as successful.

public TimeSpan Duration { get; set; } #

The last completed command's duration. Only values strictly above two seconds are shown.

Extension Methods

public static ShellPrompt WithBranch(ShellPrompt shellPrompt, string? value) #

Sets ShellPrompt.Branch: The branch name, or a detached commit identifier; null omits git information.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value string? required
The value.

Returns

ShellPrompt The same instance.
public static ShellPrompt WithDirty(ShellPrompt shellPrompt, bool value = true) #

Sets ShellPrompt.Dirty: Whether git reported working tree or index changes.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value bool = true optional
The value (default true).

Returns

ShellPrompt The same instance.
public static ShellPrompt WithDuration(ShellPrompt shellPrompt, TimeSpan value) #

Sets ShellPrompt.Duration: The last completed command's duration. Only values strictly above two seconds are shown.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value System.TimeSpan required
The value.

Returns

ShellPrompt The same instance.
public static ShellPrompt WithHome(ShellPrompt shellPrompt, string? value) #

Sets ShellPrompt.Home: The home directory, abbreviated only at a complete path boundary.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value string? required
The value.

Returns

ShellPrompt The same instance.
public static ShellPrompt WithPath(ShellPrompt shellPrompt, string value) #

Sets ShellPrompt.Path: The current provider path.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value string required
The value.

Returns

ShellPrompt The same instance.
public static ShellPrompt WithSucceeded(ShellPrompt shellPrompt, bool value = true) #

Sets ShellPrompt.Succeeded: Whether PowerShell reported the last command as successful.

Parameters

shellPrompt ConsoleMonster.Widgets.ShellPrompt required
The instance.
value bool = true optional
The value (default true).

Returns

ShellPrompt The same instance.