A library for building powerful interactive prompts inspired by python-prompt-toolkit, making it easier to build cross-platform command line tools using Nim.
- nim-chronicles. The log filtering tool chronicles_tail was the original project that lead to the creation of this library.
The provided shortcuts should be familiar to most Windows, macOS and Linux users.
Key Binding | Description |
---|---|
Home, Ctrl + A | Go to the beginning of the line |
End, Ctrl + E | Go to the end of the line |
Up Arrow, Ctrl + P | Previous command, Previous completion |
Down Arrow, Ctrl + N | Next command, Next completion |
Right Arrow, Ctrl + F | Forward one character |
Left Arrow, Ctrl + B | Backward one character |
Ctrl + Right Arrow, Alt + F | Move to next word |
Ctrl + Left Arrow, Alt + B | Move to previous word |
Delete, Ctrl + D | Delete character under the cursor |
Backspace, Ctrl + H | Delete character before the cursor |
Ctrl + Delete | Delete to end of word |
Ctrl + Backspace | Delete to beginning of word |
Tab | Trigger auto-complete, Select next completion |
Ctrl + L | Clear the screen |
Enter, Ctrl + J | Accept line |
You can use Up arrow and Down arrow to walk through the history of commands executed. An optional history file can be specified for each user program.
nim-prompt will correctly handle and display all unicode characters. In the public API, all procs use UTF-8 encoded strings on all platforms.
We have confirmed nim-prompt works fine in the following terminals:
- iTerm2, Terminal.app (macOS)
- Command Prompt (Windows)
- gnome-terminal (Ubuntu)
This software is licensed under the BSD 2-Clause license, see LICENSE for more information.