Importing this module enables command line editing using GNU Readline.
The rl.readline module contains everything known from the standard library’s readline module. The standard library documentation applies with the following exceptions:
Beyond that, rl.readline adds a plethora of new functionality which is documented in the high-level interfaces Completer, Completion, and History. Functions not exposed through a high-level interface:
Add a line to the readline history.
Clear the current readline history.
Complete the word at or before the cursor position.
Display a list of matches in columnar format on readline’s output stream.
A built-in generator function for filename completion.
Get the beginning index of the readline tab-completion scope.
Get the function that determines whether or not a specific character in the line buffer is quoted.
Get the current completion entry function.
Get the readline word delimiters for tab-completion.
Get list of characters that may be used to quote a substring of the line.
Get the character appended after the current completion.
Get the current completion display function.
When readline is completing quoted text, it sets this variable to True if the word being completed contains any quoting character (including backslashes).
Up to this many items will be displayed in response to a possible-completions call.
When readline is completing quoted text, it sets this variable to the quoting character found.
Do not append the completion_append_character after the current completion.
Do not append a matching quote character when performing completion on a quoted string.
Get the type of completion being attempted.
A function to call when readline is deciding where to separate words for word completion.
Return the current (not the maximum) length of history.
This function is allowed to modify the directory portion of filenames readline completes.
Get the ending index of the readline tab-completion scope.
If True, treat the results of matches as filenames.
Get the current filename dequoting function.
Get list of characters that cause a filename to be quoted by the completer.
If True, filenames will be quoted.
Get the current filename quoting function.
Return the current contents of history item at pos.
Return a forward iterator over the history (oldest to newest).
Return the maximum number of items written to the history file.
Return the entire history as a Python list. Element 0 of the list is the beginning of time.
Return the current history size limit.
Return a reverse iterator over the history (newest to oldest).
This function may filter the results of filename completion.
If True, completion is disabled.
Return the current contents of the line buffer.
Get the current pre_input_hook function.
Return rl_end.
Return rl_point.
Characters that are word break characters, but should be left in text when it is passed to the completion function.
Get the current startup_hook function.
True if a history size limit is set.
Insert text into the command line.
Parse and execute single line of a readline init file.
Load a readline history file. The default filename is ~/.history.
Parse a readline initialization file. The default filename is the last filename used.
Read a key from readline’s input stream, typically the keyboard. Returns characters inserted with stuff_char() before starting to read from the stream.
Return the readline library version encoded in an integer. The format is 0xMMmm, where MM is the major and mm the minor version number.
Update the screen to reflect the current contents of the line buffer. If force is True, readline redisplays the prompt area as well as the line.
Remove history item given by its position.
Replace history item given by its position with string.
Replace the line buffer contents with string.
Set the beginning index of the readline tab-completion scope.
Set or remove the function that determines whether or not a specific character in the line buffer is quoted. The function is called as function(text, index) and should return True if the character at index is quoted, and False otherwise.
Set or remove the completion entry function. The function is called as function(text, state), for state in 0, 1, 2, ..., until it returns None. It should return the next possible completion starting with text.
Set the readline word delimiters for tab-completion.
Set list of characters that may be used to quote a substring of the line.
Set the character appended after the current completion. May only be called from within custom completers.
Set or remove the completion display function. The function is called as function(substitution, matches, longest_match_length) once each time matches need to be displayed.
When readline is completing quoted text, it sets this variable to True if the word being completed contains any quoting character (including backslashes).
Up to this many items will be displayed in response to a possible-completions call.
When readline is completing quoted text, it sets this variable to the quoting character found.
Do not append the completion_append_character after the current completion. May only be called from within custom completers.
Do not append a matching quote character when performing completion on a quoted string. May only be called from within custom completers.
Set the type of completion being attempted.
A function to call when readline is deciding where to separate words for word completion. The function is called as function(begidx, endidx) once for every completion, and should return a string of word break characters for the current completion, or None to indicate no change.
This function is allowed to modify the directory portion of filenames readline completes. The function is called as function(dirname) and should return a new directory name or None to indicate no change. At the least, the function must perform all necessary dequoting.
Set the ending index of the readline tab-completion scope.
If True, treat the results of matches as filenames. May only be called from within custom completers.
Set or remove the filename dequoting function. The function is called as function(text, quote_char) and should return a string representing a dequoted version of text, or None to indicate no change.
Set list of characters that cause a filename to be quoted by the completer.
If True, filenames will be quoted. May only be called from within custom completers.
Set or remove the filename quoting function. The function is called as function(text, single_match, quote_char) and should return a string representing a quoted version of text, or None to indicate no change. The single_match argument is True if the completion has generated only one match.
Set the maximum number of items written to the history file. A negative value inhibits history file truncation.
This function may filter the results of filename completion. The function is called as function(substitution, matches) and should return a filtered subset of matches or None to indicate no change.
If True, completion is disabled and the completion character is inserted as any other character.
Set or remove the pre_input_hook function. The function is called with no arguments after the first prompt has been printed and just before readline starts reading input characters.
Characters that are word break characters, but should be left in text when it is passed to the completion function.
Set or remove the startup_hook function. The function is called with no arguments just before readline prints the first prompt.
Limit the history size to max_entries entries.
Insert a character into readline’s input stream. Returns True if the insert was successful.
Return a new string which is the result of tilde expanding string.
Remove the history size limit.
A built-in generator function for username completion.
Save a readline history file. The default filename is ~/.history.