History Support

Readline history support.

History Interface

class rl.History

Interface to the readline history.

This class is not intended for instantiation beyond the one history object in this module. Typically, applications will import the history object and use its properties and methods to work with readline history:

from rl import history

history.max_entries = 300
history.read_file(histfile)

History entries can be accessed like elements in a Python list. The item at index 0 is the oldest, the item at -1 the most recent history entry.

History.max_entries

The maximum number of history entries kept. Beyond this point the history list is truncated by removing the oldest entry. A negative value means no limit. Defaults to -1.

History.append(line)

Append a line to the history.

History.__getitem__(index)

Return the history item at index.

History.__setitem__(index, line)

Replace the history item at index.

History.__delitem__(index)

Remove the history item at index.

History.__len__()

The current history length.

History.__iter__()

Iterate over history items.

History.__reversed__()

Reverse-iterate over history items.

History.clear()

Clear the history.

History.read_file(filename=None, raise_exc=False)

Load a readline history file. The default filename is ~/.history. If raise_exc is True, IOErrors will be allowed to propagate.

History.write_file(filename=None, raise_exc=False)

Save a readline history file. The default filename is ~/.history. If raise_exc is True, IOErrors will be allowed to propagate.

History.reset()

Clear the history and reset all variables to their default values.

Table Of Contents

Previous topic

Completion Support

Next topic

Readline Bindings