UglyPrompt 0.4.0

dotnet add package UglyPrompt --version 0.4.0
                    
NuGet\Install-Package UglyPrompt -Version 0.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="UglyPrompt" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UglyPrompt" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="UglyPrompt" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UglyPrompt --version 0.4.0
                    
#r "nuget: UglyPrompt, 0.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package UglyPrompt@0.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UglyPrompt&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=UglyPrompt&version=0.4.0
                    
Install as a Cake Tool

UglyPrompt

A no-frills readline-style console line editor for .NET. Backslash continuation, ambient completion hints, bracketed paste, and history — with no external dependencies.

A permissively-licensed alternative to PrettyPrompt.

Installation

dotnet add package UglyPrompt

Usage

var editor = new LineEditor();

while (true)
{
    string? input = editor.ReadLine(">> ");
    if (input == null) continue; // whitespace-only input
    Console.WriteLine(input);
}

ReadLine returns null on whitespace-only input. It handles backslash continuation internally — the returned string is the fully-joined multi-line value.

Completion Hints

Register one or more CompletionSources to enable ambient hint dispatch. Each source carries a trigger character, an anchor rule (LineStart or WordStart), and a Lookup callback that returns matching candidates for the body typed after the trigger:

var commands = new[]
{
    new CompletionHint("/help",  "Show help"),
    new CompletionHint("/clear", "Clear the screen"),
};

var editor = new LineEditor();

editor.AddSource(new CompletionSource('/', TriggerAnchor.LineStart,
    body => commands
        .Where(c => c.Name.StartsWith("/" + body, StringComparison.OrdinalIgnoreCase))
        .ToList()));

editor.AddSource(new CompletionSource('@', TriggerAnchor.WordStart,
    body => EnumerateMatchingFiles(body)));

When the cursor is preceded by a registered trigger satisfying its anchor, a terse comma-separated list of matching names from Lookup is shown on an ephemeral line below the input. Closer-to-cursor triggers win when multiple are present. The hint is display-only — the user still types the full input and presses Enter to submit. Editing (arrows, history, Ctrl+U/W, etc.) works normally throughout.

AddSource rejects duplicate trigger chars; if you want to overload a trigger, combine candidates inside a single Lookup callback.

Lookup runs synchronously on every keystroke. Cheap for static lists; if your source needs heavy I/O, gate it behind a body-length threshold (body.Length < 3 ? [] : Search(body)) or pre-cache.

See UglyPrompt.Demo/Program.cs for a runnable example wiring /, +, and @ together.

Features

  • History — Up/Down arrows or Ctrl+P/N to navigate previous inputs
  • Backslash continuation — Lines ending with \ prompt for more input; the full value is returned joined with newlines
  • Bracketed paste — Handles terminal paste sequences including embedded newlines
  • Standard line editing — Home/End, Ctrl+A/E, Ctrl+U/K/W, Ctrl+T, and more (see below)
  • No dependencies — Only the .NET standard library; targets .NET 10.0

Keyboard Shortcuts

Keys Action
Left / Ctrl+B Move cursor left
Right / Ctrl+F Move cursor right
Home / Ctrl+A Move to start of line
End / Ctrl+E Move to end of line
Backspace / Ctrl+H Delete character before cursor
Delete / Ctrl+D Delete character at cursor
Ctrl+U Delete to start of line
Ctrl+K Delete to end of line
Ctrl+W Delete word before cursor
Ctrl+T Transpose characters
Ctrl+L / Escape Clear line
Up / Ctrl+P Previous history entry
Down / Ctrl+N Next history entry

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 130 7/9/2026
0.2.2 135 4/24/2026
0.2.1 109 4/23/2026
0.2.0 119 4/22/2026
0.1.1 106 4/17/2026
0.1.0 112 4/16/2026