GNU readline support for Python on platforms without readline
—
Core configuration functions for setting up readline behavior, parsing initialization files, and configuring the readline environment. These functions control how readline interprets key bindings, editing modes, and other behavioral settings.
Executes individual readline configuration commands, allowing runtime configuration of readline behavior without requiring configuration files.
def parse_and_bind(string):
"""
Parse and execute single line of a readline init file.
Parameters:
- string (str): Configuration command to parse and execute
Returns:
None
Raises:
None - silently ignores invalid configuration strings
"""Usage Example:
import readline
# Enable tab completion
readline.parse_and_bind('tab: complete')
# Set vi editing mode
readline.parse_and_bind('set editing-mode vi')
# Configure key bindings
readline.parse_and_bind('"\C-p": previous-history')
readline.parse_and_bind('"\C-n": next-history')
# Set completion settings
readline.parse_and_bind('set completion-ignore-case on')
readline.parse_and_bind('set show-all-if-ambiguous on')Reads and parses a complete readline initialization file, processing all configuration commands contained within the file.
def read_init_file(filename=None):
"""
Parse a readline initialization file.
Parameters:
- filename (str, optional): Path to initialization file to read.
If None, uses the default or last filename used.
Returns:
None
Raises:
IOError: If the file cannot be read or does not exist
"""Usage Example:
import readline
# Read default initialization file (~/.inputrc)
readline.read_init_file()
# Read custom initialization file
readline.read_init_file('/path/to/custom.inputrc')
# Read application-specific config
readline.read_init_file('./myapp_readline.conf')Common Configuration Options:
Readline configuration supports many options that can be set via parse_and_bind() or initialization files:
set editing-mode vi / set editing-mode emacs - Set editing modeset completion-ignore-case on/off - Case-insensitive completionset show-all-if-ambiguous on/off - Show all matches immediatelyset visible-stats on/off - Display file type indicatorsset mark-symlinked-directories on/off - Mark symlinked directories"key-sequence": function-nameInstall with Tessl CLI
npx tessl i tessl/pypi-readline