Giter Club home page Giter Club logo

prettyprompt's Introduction

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
    • Multi-line input
    • 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.
    • Works "in-line" on the command line; it doesn't take over the entire terminal window.
  • Developer Experience (DX) features:
    • Provides a CancellationToken for each prompt result, so the end-user of your application can cancel long running tasks via Ctrl-C.
    • Supports registering callbacks for key presses, to customize application behavior.
    • Optionally detects incomplete lines and converts Enter to a "soft newline" (Shift-Enter).
    • 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 target .NET 5, and can be built with either Visual Studio or the normal dotnet build command line tool.

prettyprompt's People

Contributors

kindermannhubert avatar waf avatar ivanjx avatar

Stargazers

Lav avatar Byte Wizard avatar  avatar y.kankaya avatar jrccrj avatar

Watchers

 avatar

Forkers

madusec ykankaya

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.