tools for creating user-friendly command-line prompt?
Asked Answered
I

1

6

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.

Iniquity answered 3/2, 2011 at 15:23 Comment(0)
G
11

Most of these use the GNU readline library

Gunplay answered 3/2, 2011 at 15:24 Comment(4)
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...Iniquity
The commercial version of MySQL doesn't link against readline, but BSD-licensed libedit.Injury
BTW: are you familiar with any C++ wrapper for readline? Are they good?Iniquity
@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... :)Iniquity

© 2022 - 2024 — McMap. All rights reserved.