5

I notice that some programs (e.g. sqlite, mysql client) provide a command-line prompt that is very similar in capabilities to the bash's, including:

  • line editing with left and right arrows, delete, insert, ^K, etc.
  • history browsing with up and down arrows
  • ^R for reverse i-search in command history

which make me think that they are using the same toolset for this.

I'd like to create a prompt with similar capabilities in my program, which tools can I use? I prefer it to have the same functionality as in bash, so that the users would be familiar with it.

davka
  • 13,974
  • 11
  • 61
  • 86

1 Answers1

11

Most of these use the GNU readline library

Hasturkun
  • 35,395
  • 6
  • 71
  • 104
  • 1
    seems like what I was looking for, thanks! I wander how they deal with the GPL in MySql though, MySql not being a free software anymore... – davka Feb 03 '11 at 15:29
  • 3
    The commercial version of MySQL doesn't link against readline, but BSD-licensed libedit. – Matt K Feb 03 '11 at 15:33
  • 1
    BTW: are you familiar with any C++ wrapper for readline? Are they good? – davka Feb 03 '11 at 16:11
  • 1
    @mkb: funny, I just saw a "proof" of that: while playing with both readline and libedit, I noticed that one does not display ^D when pressed and the second does. Now, switching from the community version of mysql to the commercial one, I see exactly this behavior... :) – davka Feb 08 '11 at 16:39