Questions tagged [readline]

A library for command line editing, or a function to read one line of text.

Readline may refer either the GNU readline library, used for editing a command line; or a function or method in various programming languages which typically reads a line of text from an open file handle.

GNU readline library

The gnu readline library provides applications with an interactive command prompt with features like

  • flexible command editing
  • configurable key bindings to mimic e.g. or
  • a history of past commands

Probably the most prominent application using readline is . Both packages are maintained by the same person. Many programming languages provide bindings for this library.

readline function

Examples of readline functions or methods include

(please extend this list if you know more languages using this name)

2233 questions
5
votes
3 answers

Bash: call script with customized keyboard shortcuts?

Lets say I have a script, "myscript.sh", with contents being simply echo $PWD. I'd like to bind somehow this script to a key combo in bash (gnome-terminal) - so that when I press this key combination, the output of "myscript.sh" is inserted…
sdaau
  • 36,975
  • 46
  • 198
  • 278
5
votes
2 answers

Binding to Arrow Keys in Readline Library

I'm trying to bind to arrow keys in C using the GNU Readline library. I've printed out all possible combinations of ASCII (0-255) key values of rl_bind_key, but the arrow keys don't seem to be detected. How can I bind to them? static int…
James Taylor
  • 6,158
  • 8
  • 48
  • 74
5
votes
2 answers

Fixing in bash vi input mode. Cannot type beyond last character

I'm trying to use vi mode in bash. via the .inputrc (on OSX): set editing-mode vi In vi insert mode, the right arrow key moves the cursor to the right, but it stops on the last character in the line. If the cursor is past the end of the line, it…
Saevon
  • 53
  • 6
5
votes
1 answer

Why Bash can't ignore case when tab completion variable names?

When I want to input the command echo $bash_, then I press Tab key, the autocompletion can't occur. But when I input the command echo $BASH_, then I press Tab, the completion list will output like this: $BASH_ALIASES $BASH_COMMAND …
zhenguoli
  • 2,268
  • 1
  • 14
  • 31
5
votes
2 answers

"Up Arrow" history in Python on OS X and code.InteractiveConsole

I use the following trick in some of my Python scripts to drop into an interactive Python REPL session: import code; code.InteractiveConsole(locals=globals()).interact() This usually works well on various RHEL machines at work, but on my laptop (OS…
complex
  • 116
  • 4
5
votes
2 answers

Print escaped color characters to bash

I'm using the readline library in C to create a bash-like prompt within bash. When I tried to make the prompt colorful, with color sequences like these, the coloring works great, but the cursor spacing is messed up. The input is wrapped around too…
ldanilek
  • 341
  • 1
  • 11
5
votes
0 answers

PHP Readline: Get a new prompt on SIGINT

I'm writing a php cli interactive program, it act as a shell by using readline extension. But I find that when I press Ctrl + C, the whole program exits. I hope it can get a new prompt instead of exit (just like bash). So I try pcntl_signal to…
leo108
  • 817
  • 5
  • 12
5
votes
0 answers

Python - Add hook/callback for when cursor moves when entering raw_input?

I am trying to write a version of the interactive interpreter which has syntax highlighting. Here's what I have so far which works reasonably well (uses blessings and pygments modules)... import code import readline import threading import…
5
votes
2 answers

Buffered Reader read text until character

I am using a buffered reader to read in a file filled with lines of information. Some of the longer lines of text extend to be more than one line so the buffered views them as a new line. Each line ends with ';' symbol. So I was wondering if…
Waggoner_Keith
  • 590
  • 2
  • 9
  • 37
5
votes
6 answers

Python - open file - readline - list - convert to string

The Issue/Question Details I have a file (blah.txt) where its contents (a list) look like this: Key1 = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '] Inside of a simple python file…
chadbyoung
  • 53
  • 1
  • 5
5
votes
1 answer

Python cmd on linux does not autocomplete special characters or symbols

Characters such as - , + etc are not parsed the same way as alphanumeric ASCII characters by Python's readline based cmd module. This seems to be linux specific issue only, as it seems to work as expected on Mac OS. Sample code import cmd class…
rajivRaja
  • 527
  • 3
  • 6
  • 16
5
votes
2 answers

Input string in J script hangs

I write script in J for linux with #! But script hang. After Control-D script echoed entered value. But normal ENTER only put cursor on new line. #!/path/jconsole a =. 1!:1]3 echo a exit ''
5
votes
2 answers

Interfacing readline into Rust

I try to do this tutorial in rust, so far I have a lot of problems interfacing the C library into Rust. C equivalent code: #include #include #include #include int main(int argc,…
Facon
  • 679
  • 2
  • 7
  • 21
5
votes
1 answer

reading data from a textfile and displaying it on the textview

i am trying to read data from a textfile "temp.txt" which is in my raw folder and displaying the contents of the file on the text view "text" whenever a button "button" is clicked, but my app crashes while doing so, there is quite a possibility that…
Asad
  • 49
  • 1
  • 5
5
votes
4 answers

force exit from readline() function

I am writing program in c++ which runs GNU readline in separate thread. When main thread is exited I need to finish the thread in which readline() function is called. The readline() function is returned only when standart input came (enter pressed).…