CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-readline

GNU readline support for Python on platforms without readline

Pending
Overview
Eval results
Files

configuration.mddocs/

Configuration and Initialization

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.

Capabilities

Parse and Execute Configuration Commands

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')

Read Initialization File

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 mode
  • set completion-ignore-case on/off - Case-insensitive completion
  • set show-all-if-ambiguous on/off - Show all matches immediately
  • set visible-stats on/off - Display file type indicators
  • set mark-symlinked-directories on/off - Mark symlinked directories
  • Key bindings using format: "key-sequence": function-name

Install with Tessl CLI

npx tessl i tessl/pypi-readline

docs

completion.md

configuration.md

history.md

hooks.md

index.md

line-editing.md

tile.json