Readline
   HOME

TheInfoList



OR:

GNU Readline is a
software library In computing, a library is a collection of resources that can be leveraged during software development to implement a computer program. Commonly, a library consists of executable code such as compiled functions and classes, or a library can ...
that provides in-line editing and history capabilities for interactive programs with a
command-line interface A command-line interface (CLI) is a means of interacting with software via command (computing), commands each formatted as a line of text. Command-line interfaces emerged in the mid-1960s, on computer terminals, as an interactive and more user ...
, such as Bash. It is currently maintained by Chet Ramey as part of the
GNU Project The GNU Project ( ) is a free software, mass collaboration project announced by Richard Stallman on September 27, 1983. Its goal is to give computer users freedom and control in their use of their computers and Computer hardware, computing dev ...
. It allows users to move the text cursor, search the
command history Command history is a feature in many operating system shells, computer algebra programs, and other software that allows the user to recall, edit and rerun previous commands. Command line history was added to Unix in Bill Joy's C shell of 1978; ...
, control a kill ring (a more flexible version of a copy/paste clipboard) and use tab completion on a text terminal. As a
cross-platform Within computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several Computing platform, computing platforms. Some ...
library, readline allows applications on various systems to exhibit identical line-editing behavior.


Editing modes

Readline supports both Emacs and vi editing modes, which determine how keyboard input is interpreted as editor commands. See .


Emacs keyboard shortcuts

Emacs editing mode key bindings are taken from the
text editor A text editor is a type of computer program that edits plain text. An example of such program is "notepad" software (e.g. Windows Notepad). Text editors are provided with operating systems and software development packages, and can be used to c ...
Emacs Emacs (), originally named EMACS (an acronym for "Editor Macros"), is a family of text editors that are characterized by their extensibility. The manual for the most widely used variant, GNU Emacs, describes it as "the extensible, customizable, s ...
. On some systems, must be used instead of , because the shortcut conflicts with another shortcut. For example, pressing in Xfce's terminal emulator window does not move the cursor forward one word, but activates "File" in the menu of the terminal window, unless that is disabled in the emulator's settings. * :
Autocomplete Autocomplete, or word completion, is a feature in which an application software, application predicts the rest of a word a user is typing. In Android (operating system), Android and iOS smartphones, this is called predictive text. In graphical us ...
s from the cursor position. * : Moves the cursor to the line start (equivalent to the key ). * : Moves the cursor back one character (equivalent to the key ). * : Sends the signal SIGINT via pseudoterminal to the current task, which aborts and closes it. * ** Sends an EOF marker, which (unless disabled by an option) closes the current shell (equivalent to the command exit). (Only if there is no text on the current line) ** If there is text on the current line, deletes the current character (then equivalent to the key ). * : ( end) moves the cursor to the line end (equivalent to the key ). * : Moves the cursor forward one character (equivalent to the key ). * : Abort the reverse search and restore the original line. * : Deletes the previous character (same as backspace). * : Equivalent to the tab key. * : Equivalent to the enter key. * : Clears the line content after the cursor and copies it into the clipboard. * : Clears the screen content (equivalent to the command clear). * : (
next NeXT, Inc. (later NeXT Computer, Inc. and NeXT Software, Inc.) was an American technology company headquartered in Redwood City, California that specialized in computer workstations for higher education and business markets, and later develope ...
) recalls the next command (equivalent to the key ). * : Executes the found command from history, and fetch the next line relative to the current line from the history for editing. * : ( previous) recalls the prior command (equivalent to the key ). * : (reverse search) recalls the last command including the specified characters. A second recalls the next anterior command that corresponds to the search. * : Go back to the next more recent command of the reverse search (beware to not execute it from a terminal because this command also launches its XOFF). If you changed that XOFF setting, use to return. * : Transpose the previous two characters. * : Clears the line content before the cursor and copies it into the clipboard. * : If the next input is also a control sequence, type it literally (e. g. * types "^H", a literal backspace). * : Clears the word before the cursor and copies it into the clipboard. * : Edits the current line in the $EDITOR program, or vi if undefined. * : Read in the contents of the inputrc file, and incorporate any bindings or variable assignments found there. * : Incremental undo, separately remembered for each line. * : Display version information about the current instance of Bash. * : Alternates the cursor with its old position. (C-x, because x has a crossing shape). * : ( yank) adds the clipboard content from the cursor position. * : Sends the signal SIGTSTP to the current task, which suspends it. To execute it in background one can enter bg. To bring it back from background or suspension fg process name or job id'/code> ( foreground) can be issued. * : Incremental undo, separately remembered for each line. * : ( backward) moves the cursor backward one word. * : Capitalizes the character under the cursor and moves to the end of the word. * : Cuts the word after the cursor. * : ( forward) moves the cursor forward one word. * : Lowers the case of every character from the cursor's position to the end of the current word. * : Cancels the changes and puts back the line as it was in the history. * : Capitalizes every character from the cursor's position to the end of the current word. * : Insert the last argument to the previous command (the last word of the previous history entry).


Choice of the GPL as GNU Readline's license

GNU Readline is notable for being a
free software Free software, libre software, libreware sometimes known as freedom-respecting software is computer software distributed open-source license, under terms that allow users to run the software for any purpose as well as to study, change, distribut ...
library which is licensed under the
GNU General Public License The GNU General Public Licenses (GNU GPL or simply GPL) are a series of widely used free software licenses, or ''copyleft'' licenses, that guarantee end users the freedom to run, study, share, or modify the software. The GPL was the first ...
(GPL). Free software libraries are far more often licensed under the
GNU Lesser General Public License The GNU Lesser General Public License (LGPL) is a free-software license published by the Free Software Foundation (FSF). The license allows developers and companies to use and integrate a software component released under the LGPL into their own ...
(LGPL), for example, the GNU C Library, GNU gettext and FLTK. A developer of an application who chooses to link to an LGPLv3 licensed library can use any license that does not: "restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications". But linking to a ''GPLv3'' licensed library such as Readline requires the ''entire'' combined resulting application to be licensed under the GPLv3 when distributed, to comply with section 5 of the GPL. This licensing was chosen by the FSF on the hopes that it would encourage software to switch to the GPL. An important example of an application changing its licensing to comply with the copyleft conditions of GNU Readline is CLISP, an implementation of
Common Lisp Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
. Originally released in 1987, it changed to the GPL license in 1992, after an email exchange between one of CLISP's original authors, Bruno Haible, and
Richard Stallman Richard Matthew Stallman ( ; born March 16, 1953), also known by his initials, rms, is an American free software movement activist and programmer. He campaigns for software to be distributed in such a manner that its users have the freedom to ...
, in which Stallman argued that the linking of readline in CLISP meant that Haible was required to re-license CLISP under the GPL if he wished to distribute the implementation of CLISP which used readline. Another response has been to not use this in some projects, making text input use the primitive Unix terminal driver for editing.


Alternative libraries

Alternative libraries have been created with other licenses so they can be used by software projects which want to implement command line editing functionality, but be released with a non-GPL license. * Many BSD systems have a BSD-licensed ''libedit''.
MariaDB MariaDB is a community-developed, commercially supported Fork (software development), fork of the MySQL relational database management system (RDBMS), intended to remain free and open-source software under the GNU General Public License. Developm ...
and PHP allow for the user to select at build time whether to link with GNU Readline or with libedit. * ''linenoise'' is a tiny C library that provides line editing functions. it is prominently used by MongoDB and Redis. It was integrated into Android in 2010, but has since been deprecated. * ''Haskeline'' is a BSD-3-Clause licensed readline-like library for Haskell. It is mainly written for the Glasgow Haskell Compiler, but is available to other Haskell projects which need line-editing services as well. * ''PSReadLine'' is a BSD-2-Clause licensed readline implementation written in C# for
PowerShell PowerShell is a shell program developed by Microsoft for task automation and configuration management. As is typical for a shell, it provides a command-line interpreter for interactive use and a script interpreter for automation via a langu ...
inspired by bash and GNU Readline


Sample code

The following code is in C and must be linked against the readline library by passing a flag to the compiler: #include #include #include #include int main()


Bindings

Non-C programming languages that provide language bindings for readline include * Python's built-in module; * Ruby's built-in module; * Perl's third-party (CPAN) module, specifically for GNU ReadLine. * PHP's extension. Support for readline alternatives differ among these bindings.


Notes


References


External links


Things You Didn't Know About GNU Readline
{{DEFAULTSORT:Gnu Readline Free software programmed in C Readline Text user interface libraries Termcap