Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 224
punekr12 Avatar asked Jul 31 '13 23:07

punekr12


2 Answers

This is an admirable goal I think :-)

Perhaps Linenoise, libedit/editline or tecla would fit the bill?

Of those probably libedit is the most widely used - e.g. postgreqsql client shell and various BSD utilities for Kerberos and ntp (although for the upstream sources it may not be the default line editing library for compilation due the to widespread use of libreadline on Linux). There are a couple of slightly different versions of libedit/editline as you'll see if you read some of those references and do some further research.

Cheers, and good luck with your project.

like image 120
G. Cito Avatar answered Nov 12 '22 21:11

G. Cito


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
like image 42
AmokHuginnsson Avatar answered Nov 12 '22 19:11

AmokHuginnsson