• Stars
    star
    152
  • Rank 236,882 (Top 5 %)
  • Language
    C#
  • License
    Mozilla Public Li...
  • Created about 3 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A cross-platform command line input library that provides syntax highlighting, autocompletion, history and multi-line input.

PrettyPrompt

Nuget Code Coverage Build Status

A cross-platform command line prompt that provides syntax highlighting, autocompletion, history and more! It's Console.ReadLine() on steroids.

PrettyPrompt screenshot

Features

  • User Experience (UX) features:
    • Syntax highlighting support via ANSI escape sequences. Supports both the terminal color palette and full RGB colors.
    • Autocompletion menu, with extended documentation tooltips and overload menus.
    • Multi-line input with word-wrapping
    • Word-wrapping
    • History navigation, optionally persistent across sessions, with history filtering (similar to PSReadLine's HistorySearchBackward).
    • Unsurprising keybindings: Home, End, Ctrl-L to clear screen, Ctrl-C to cancel current line, Ctrl+Space to open autocomplete menu, and more.
    • Cross platform copy/paste: Ctrl-Shift-C for copy, Ctrl-V or Shift-Insert for pasting.
    • Optionally detects incomplete lines and converts Enter to a "soft newline" (Shift-Enter).
    • Optionally autoformats input text as it's typed.
    • Works "in-line" on the command line; it doesn't take over the entire terminal window.
  • Developer Experience (DX) features:
    • Many customization hooks available for configuring PrettyPrompt for your application (see IPromptCallbacks).
    • Provides a CancellationToken for each prompt result, so the end-user of your application can cancel long running tasks via Ctrl-C.
    • Fast rendering—PrettyPrompt only renders the diff of what changed, so the screen doesn't flicker as text is redrawn.

Installation

PrettyPrompt can be installed from nuget by running the following command:

dotnet add package PrettyPrompt

Usage

A simple read-eval-print-loop looks like this:

var prompt = new Prompt();

while (true)
{
    var response = await prompt.ReadLineAsync("> ");
    if (response.IsSuccess) // false if user cancels, i.e. ctrl-c
    {
        if (response.Text == "exit") break;

        Console.WriteLine("You wrote " + response.Text);
    }
}

The Prompt constructor takes optional configuration options for enabling syntax highlighting, autocompletion, and soft-newline configuration. For a more complete example, see the project in the examples directory. If you have the dotnet example global tool installed, run the following command in the repository root:

dotnet example FruitPrompt

Building from source

This application targets modern .NET (i.e. not .NET Framework), and can be built with either Visual Studio or the normal dotnet build command line tool.

More Repositories

1

CSharpRepl

A command line C# REPL with syntax highlighting – explore the language, libraries and nuget packages interactively.
C#
2,505
star
2

WCF-Binary-Message-Inspector

Inspect and modify WCF Binary Messages in Fiddler
C#
77
star
3

replay-csharp

An editable C# REPL (Read Eval Print Loop) powered by Roslyn and .NET Core
C#
76
star
4

nice-and-clean-theme

A port of the Openbox "nice and clean" theme for awesome window manager
Lua
35
star
5

push-demo

Use clojure with datomic's tx-report-queue to push changes to the client via websockets
JavaScript
18
star
6

MiniTerm

Experiments with the new Windows PTY APIs
C#
12
star
7

anki-thai

Build an Thai Vocab Anki deck from a JSON file
Python
10
star
8

Donatello

Donatello is a DotNet lisp-like language
C#
9
star
9

RunOnSave

A Visual Studio extension that can run commands on files when they're saved.
C#
6
star
10

Catchy

A caching proxy for local development
C#
6
star
11

chow-chooser

A realtime voting system for one of life's most important questions: Where the hell should we go for lunch?
JavaScript
6
star
12

Formic

Given an EF Core DbContext, generate an admin CRUD site at runtime
C#
5
star
13

Monet

Option and Result types for .NET, a la Rust
C#
4
star
14

js-framework-generator

Markov generator for JavaScript frameworks, written in WebAssembly (C#)
C#
4
star
15

config

Miscellaneous Linux configuration files
Vim Script
3
star
16

System.IO.Pipelines-Playground

Playing around with System.IO.Pipelines https://stackoverflow.com/questions/64283938
C#
3
star
17

strack

A slack client written in Rust and GTK+
Rust
3
star
18

ZebraPuzzle

C# solution to the Zebra Puzzle based on Peter Norvig's python solution
C#
3
star
19

MonadsInCSharp

demo code for Monads in C# talk
C#
3
star
20

slime-ball-js

Slime Volleyball implemented in javascript
JavaScript
2
star
21

latex-presentation

My part of a two-part presentation on LaTeX for Michigan!/usr/group
TeX
2
star
22

boidjs

JavaScript flocking simulator using the Boids algorithm
JavaScript
2
star
23

waf.github.com

Source of fuqua.io
HTML
2
star
24

angular-presentation

AngularJS presentation and sample projects
JavaScript
2
star
25

DotNetConfThailand.2022.CSharp11

Jupyter Notebook
2
star
26

Nessie

.net static site engine
C#
2
star
27

thai-cards

Flashcards for learning the Thai language
JavaScript
1
star
28

firebrand

F# IRC Library and Bot
F#
1
star
29

russell

matrix.org bot written in Rust
Rust
1
star
30

Logic

uKanren in C# with a LINQ interface
C#
1
star
31

thai-characters

Web app to help learn thai language characters
JavaScript
1
star
32

ReuSQL

Prototyping code reuse in SQL using Dapper and T4 templates
C#
1
star
33

taskapi

Clojure
1
star
34

scalawag

Simple IRC Bot written in Scala
Scala
1
star
35

sharpie

C# IRC bot - mainly an excuse to play around with TPL Dataflow
C#
1
star
36

airport-wifi

JavaScript
1
star
37

SpeechBin

experiment with blazor and browser speech APIs
HTML
1
star
38

DevServer

Development server suitable for embedding in dotnet / corert applications.
C#
1
star
39

AspNetCoreMvcToStringExample

Example of rendering an asp.net mvc core action to a string with no HttpContext required
C#
1
star
40

BreakpointsPerBranch

Automatically associates your Visual Studio breakpoints with the current git branch. Switching branches restores the associated breakpoints.
C#
1
star
41

ogre3d-empty-workspace

A cmake-based workspace for Ogre3D applications under linux
C++
1
star
42

cotm-clojure

Clojure rewrite of https://github.com/craigmaloney/command_moment for fun
Clojure
1
star
43

flapibird

Experimental desktop app written in Flutter. It's a UI for a rest client. The actual rest client isn't working yet!
C++
1
star
44

cleric

IRC bot that can dynamically add commands based on twitter sources
Clojure
1
star
45

MultipleDispatchBenchmarks

Benchmarking various approaches to multiple dispatch in C#
C#
1
star
46

flash-cards

Flash Cards to help learn the Thai language
JavaScript
1
star