5

GitHub - reeflective/readline: Shell library with modern and simple UI features

 1 year ago
source link: https://github.com/reeflective/readline
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Readline

Shell library with modern and simple UI features

This library is a modern, pure Go readline implementation, enhanced with editing and user interface features commonly found in modern shells, all in little more than 10K lines of code. Its kemap-based model and completion engine is heavily inspired from the Z-Shell architecture. It is used, between others, to power the console library.

Features

Editing

  • Near-native Emacs and Vim modes.
  • Configurable bind keymaps, with live reload and sane defaults.
  • Extended list of edition/movement/control widgets (Emacs and Vim).
  • Extended surround select/change/add fonctionality, with highlighting.
  • Keywords switching (operators, booleans, hex/binary/digit) with iterations.
  • Support for Vim Visual/Operator pending mode & cursor styles indications.
  • Vim Insert and Replace (once/many).
  • Many Vim text objects.
  • All Vim registers, with completion support.
  • Undo/redo history.
  • Command-line edition in $EDITOR.
  • Support for an arbitrary number of history sources.

Interface

  • Support for most of oh-my-posh prompts (PS1/PS2/RPROMPT/transient/tooltip).
  • Extended completion system, keymap-based and configurable, easy to populate & use.
  • Multiple completion display styles, with color support.
  • Completion & History incremental search system & highlighting (fuzzy-search).
  • Automatic & context-aware suffix removal for efficient flags/path/list completion.
  • Optional asynchronous autocomplete.
  • Usage/hint message display.
  • Support for syntax highlighting

Documentation

Readline is used by the console library and its example binary. To get a grasp of the functionality provided by readline and its default configuration, install and start the binary.

Showcases

- Emacs edition- Vim edition- Undo/redo line history - Keyword switching - Vim selection & movements (basic) - Vim surround (selection and change) - Vim registers (with completion) - History movements/completion/use/search History movement, completion and some other other widgets

- Completion - Suffix autoremoval - Prompts - Logging - Configuration hot-reload

Status

This library is in a pre-release status, although pretending to be quite bug-free as compared to its feature set. Please open a PR or an issue if you wish to bring enhancements to it. Other contributions, as well as bug fixes and reviews are also welcome.

Credits

  • While most of the code has been rewritten from scratch, the original library used is lmorg/readline. I would have never ventured myself doing this if he had not ventured writing a Vim mode core in the first place.
  • Some of the Vim code is inspired or translated from zsh-vi-mode.

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK