'Lightweight GNU readline alternative

I am looking for a GNU readline alternative. It comes with a lot of features but only couple of them are useful to me as explained below -

I am working on a interactive command prompt application (display prompt and accept next user command to be run). I want to implement some editing and history feature for the prompt. So when the user presses UP key it should show the last run command. Also, user should be able to navigate using arrow keys if he need to edit any typo or command switches etc.

On windows something similar already exists, if you use fgets or scanf to get the input on cmd prompt it already maintains history and also lets you edit.

Is there a good option available on linux?



Solution 1:[1]

There is replxx, a BSD licensed alternative to readline. It works in Linux, BSD, Solaris and Windows. It has support for features you expect from interactive console programs, namely:

  • line editing
  • history
  • syntax highlighting
  • hints
  • UTF-8
  • user defined key bindings (supporting (shift/ctrl)F1 - F12)
  • multi-threaded print

Solution 2:[2]

I think the modern alternative of GNU Readline is Jupyter Notebook. The idea is that you don't create an executable that links to a line editor library. Instead, you should just provide the kernel and the users can choose their own notebook UI, either CUI, web based GUI, or even an IDE like VS Code.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AmokHuginnsson
Solution 2 Yang Bo