ReadLine.Reboot
3.1.1
Please use Terminaux to take advantage of all the features that this library provides.
See the version list below for details.
dotnet add package ReadLine.Reboot --version 3.1.1
NuGet\Install-Package ReadLine.Reboot -Version 3.1.1
<PackageReference Include="ReadLine.Reboot" Version="3.1.1" />
paket add ReadLine.Reboot --version 3.1.1
#r "nuget: ReadLine.Reboot, 3.1.1"
// Install ReadLine.Reboot as a Cake Addin #addin nuget:?package=ReadLine.Reboot&version=3.1.1 // Install ReadLine.Reboot as a Cake Tool #tool nuget:?package=ReadLine.Reboot&version=3.1.1
ReadLine.Reboot
ReadLine.Reboot is a reboot of Toni Solarin-Sodara's original ReadLine that is discontinued. It's a GNU Readline like library built in pure C#. It can serve as a drop in replacement for the inbuilt Console.ReadLine()
and brings along with it some of the terminal goodness you get from Unix shells, like command history navigation and tab auto completion.
It is cross platform and runs anywhere .NET is supported, as long as they run on .NET Framework 4.8 or at least .NET Core 3.1.
Shortcut Guide
Note: Some keys conflict with terminal emulator keybindings.
Keybinding | Action |
---|---|
Ctrl +A / HOME |
Beginning of line |
Ctrl +E / END |
End of line |
Ctrl +B / ← |
Backward one character |
Ctrl +F / → |
Forward one character |
Alt +B |
Backward one word |
Alt +F |
Forward one word |
Ctrl +C |
Send EOF |
Ctrl +H / Backspace |
Delete previous character |
Ctrl +D / Delete |
Delete succeeding character / End of line if nothing |
Ctrl +L / Esc |
Clear line |
Ctrl +U |
Cut text to the start of line |
Ctrl +K |
Cut text to the end of line |
Ctrl +W / Alt +Backspace |
Cut previous word |
Alt +D |
Cut next word |
Alt +\ |
Cut horizontal line |
Ctrl +Y |
Yank (paste the cut content) |
Ctrl +T |
Switch two characters |
Alt +T |
Switch two words |
Alt +L |
Make word lowercase |
Alt +U |
Make word uppercase |
Alt +C |
Make char uppercase and move to the end of word |
Alt +V |
Make char lowercase and move to the end of word |
Shift +Alt +# |
Add comment # to the beginning of the line |
Alt +Tab |
Insert the TAB character verbatim * |
Shift +Alt +& |
Perform tilde expansion |
Ctrl +J / Enter |
End of line |
Ctrl +Shift +_ |
Undo the last change ** |
Alt +R |
Undos all the changes |
Ctrl +N / ↓ |
Forward in history |
Ctrl +P / ↑ |
Backward in history |
Shift +Alt +< |
First history |
Shift +Alt +> |
Last history (Go back to current line) |
Alt +. |
Add last argument to current input |
Ctrl +I / Tab |
Command line completion |
Shift +Ctrl +I / Shift +Tab |
Backwards command line completion |
Shift +Alt +* |
Dump all suggestions to current line |
*
: Conflicts withAlt
+Tab
on Windows.**
: Conflicts withCtrl
+Shift
+_
on Windows Command Prompt
Installation
Available on NuGet
Visual Studio:
PM> Install-Package ReadLine.Reboot
.NET Core CLI:
dotnet add package ReadLine.Reboot
Comparison
Here, we'll compare some of the base features between Original ReadLine, Latency's ReadLine, and ReadLine.Reboot.
Feature | Original | Latency's | ReadLine.Reboot | Notes |
---|---|---|---|---|
CTRL + A / HOME |
Works | Works | Works | |
CTRL + E / END |
Works | Works | Works | |
CTRL + B / LEFT |
Works | Malfunction | Works | Cursor goes backwards too much until the crash occurs |
CTRL + F / RIGHT |
Works | Works | Works | |
CTRL + C |
Nonfunctional | Malfunction | Works | Unimplemented in original, Latency's implementation just always exits the app, Ours works if you have CtrlCEnabled set to true |
CTRL + H / BACKSPACE |
Works | Malfunction | Works | Cursor goes backwards too much until the crash occurs |
CTRL + D / DEL |
Works | Works | Works | |
CTRL + L / ESC |
Works | Malfunction | Works | Cursor goes backwards too much until the crash occurs |
CTRL + U |
Works | Malfunction | Works | Cursor goes backwards too much until the crash occurs |
CTRL + K |
Works | Malfunction | Works | Cursor goes backwards too much until the crash occurs |
CTRL + W |
Partial | Partial | Works | Wipe all whitespace before erasure in original and Latency's |
ALT + BACKSPACE |
Nonfunctional | Malfunction | Works | Unimplemented in original and Latency, cursor goes backwards too much until the crash occurs (Latency) |
CTRL + T |
Works | Malfunction | Works | Corrupts output |
CTRL + J |
Partial | Partial | Works | Appends ACTUAL newline on Windows in original and Latency's |
CTRL + N / DOWN (history) |
Partial | Malfunction | Works | Clears line in original, corrupts output in Latency's |
CTRL + P / UP (history) |
Partial | Malfunction | Works | Clears line in original, corrupts output in Latency's |
TAB (autocomplete) |
Works | Works | Works | |
TAB (no autocomplete) |
Partial | Partial | Works | Whole ReadLine doesn't really support tab chars, ReadLine.Reboot treats tabs as eight spaces |
SHIFT + TAB (autocomplete) |
Works | Works | Works | |
SHIFT + TAB (no autocomplete) |
Partial | Partial | Works | Whole ReadLine doesn't really support tab chars, ReadLine.Reboot treats tabs as eight spaces |
Usage
This section shows you how to use this library to read the lines and manage history. Just add this to the top of the source file you want to use ReadLine.Reboot on:
using ReadLineReboot;
Input
Note: The (prompt>)
is optional
Read input
string input = ReadLine.Read("(prompt)> ");
Read input with default
string input = ReadLine.Read("(prompt)> ", "default");
Read input with custom prompt handler
ReadLine.WritePrompt = (prompt) => Console.Write($">> {prompt}");
string input = ReadLine.Read("(prompt)> ", "default");
Read password
string password = ReadLine.ReadPassword("(prompt)> ");
Read password with password mask
string password = ReadLine.ReadPassword("(prompt)> ", '*');
Interrupt reading
ReadLine.Interruptible = true;
ReadLine.InterruptRead();
History management
Note: History information is persisted for an entire application session. Also, calls to ReadLine.Read()
automatically adds the console input to history
// Get command history
ReadLine.GetHistory();
// Add command to history
ReadLine.AddHistory("dotnet run");
// Clear history
ReadLine.ClearHistory();
// Set history
List<string> newHistory = new() { "apt update", "apt dist-upgrade" };
ReadLine.SetHistory(newHistory);
// Disable history (default)
ReadLine.HistoryEnabled = false;
// Enable history
ReadLine.HistoryEnabled = true;
Auto-Completion
Note: If no "AutoCompletionHandler" is set, tab autocompletion will be disabled
class AutoCompletionHandler : IAutoCompleteHandler
{
// characters to start completion from
public char[] Separators { get; set; } = new char[] { ' ', '.', '/' };
// text - The current text entered in the console
// index - The index of the terminal cursor within {text}
public string[] GetSuggestions(string text, int index)
{
if (text.StartsWith("git "))
return new string[] { "init", "clone", "pull", "push" };
else
return null;
}
}
ReadLine.AutoCompletionHandler = new AutoCompletionHandler();
You can disable and enable the auto-completion feature below.
// Disable history (default)
ReadLine.AutoCompletionEnabled = false;
// Enable history
ReadLine.AutoCompletionEnabled = true;
Credits
Author | For |
---|---|
Toni Solarin-Sodara | Original ReadLine |
EoflaOE | Rebooting the ReadLine project |
License
MIT License
Copyright (c) 2017 Toni Solarin-Sodara
Copyright (c) 2022 EoflaOE and its companies
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
net6.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 | |
---|---|---|---|
3.4.1 | 6,577 | 8/25/2022 | |
3.4.0 | 3,093 | 8/4/2022 | |
3.4.0-build167 | 197 | 9/15/2022 | |
3.4.0-build166 | 187 | 8/25/2022 | |
3.4.0-build165 | 181 | 8/25/2022 | |
3.4.0-build164 | 173 | 8/13/2022 | |
3.4.0-build163 | 190 | 8/8/2022 | |
3.4.0-build162 | 186 | 8/4/2022 | |
3.4.0-build161 | 188 | 8/4/2022 | |
3.4.0-build160 | 188 | 8/4/2022 | |
3.4.0-build159 | 188 | 8/4/2022 | |
3.4.0-build158 | 188 | 8/4/2022 | |
3.4.0-build157 | 185 | 8/4/2022 | |
3.4.0-build156 | 186 | 8/3/2022 | |
3.4.0-build155 | 180 | 8/3/2022 | |
3.4.0-build154 | 188 | 8/3/2022 | |
3.4.0-build153 | 184 | 8/3/2022 | |
3.4.0-build152 | 188 | 8/3/2022 | |
3.4.0-build151 | 171 | 8/3/2022 | |
3.4.0-build150 | 189 | 8/3/2022 | |
3.4.0-build149 | 191 | 8/3/2022 | |
3.4.0-build148 | 182 | 8/3/2022 | |
3.4.0-build147 | 196 | 8/3/2022 | |
3.4.0-build146 | 197 | 7/31/2022 | |
3.4.0-build145 | 195 | 7/28/2022 | |
3.3.2 | 2,453 | 7/26/2022 | |
3.3.2-build144 | 199 | 7/28/2022 | |
3.3.2-build143 | 199 | 7/26/2022 | |
3.3.2-build142 | 191 | 7/26/2022 | |
3.3.2-build141 | 215 | 7/19/2022 | |
3.3.1 | 1,061 | 7/19/2022 | |
3.3.1-build140 | 209 | 7/19/2022 | |
3.3.1-build137 | 201 | 7/18/2022 | |
3.3.1-build136 | 292 | 7/17/2022 | |
3.3.1-build135 | 203 | 7/17/2022 | |
3.3.1-build134 | 216 | 7/17/2022 | |
3.3.1-build133 | 201 | 7/17/2022 | |
3.3.1-build132 | 204 | 7/17/2022 | |
3.3.1-build131 | 217 | 7/17/2022 | |
3.3.1-build130 | 206 | 7/16/2022 | |
3.3.1-build129 | 210 | 7/16/2022 | |
3.3.1-build112 | 191 | 7/14/2022 | |
3.3.1-build111 | 208 | 7/14/2022 | |
3.3.1-build110 | 207 | 7/12/2022 | |
3.2.0 | 913 | 7/9/2022 | |
3.1.2 | 1,623 | 6/8/2022 | |
3.1.1 | 493 | 6/8/2022 | |
3.1.0 | 487 | 6/8/2022 | |
3.0.1 | 576 | 6/2/2022 | |
3.0.0 | 463 | 6/1/2022 |