Skip to content
Back to top
View this page
Edit this page

# xonsh.shells.ptk_shell.history

History object for use with prompt_toolkit.

class xonsh.shells.ptk_shell.history.PromptToolkitHistory(load_prev=True, *args, **kwargs)

  History class that implements the prompt-toolkit history interface with the xonsh backend.

  Initialize history object.

  append_string(string: str) → None

    Add string to the history.

  get_strings() → list[str]

    Get the strings from the history that are loaded so far. (In order. Oldest item first.)

  async load() → AsyncGenerator[str, None]

    Load the history and yield all the entries in reverse order (latest, most recent history entry first).

    This method can be called multiple times from the Buffer to repopulate the history when prompting for a new input. So we are responsible here for both caching, and making sure that strings that were were appended to the history will be incorporated next time this method is called.

  load_history_strings()

    Loads synchronous history strings

  store_string(entry)

    Store the string in persistent storage.