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

# xonsh.shells.ptk_shell

The prompt_toolkit based xonsh shell.

class xonsh.shells.ptk_shell.PromptToolkitShell(**kwargs)

  The xonsh shell for prompt_toolkit v2 and later.

  Notes

  classes inheriting multiple base classes should call them explicitly as done for `ReadlineShell`

  cmdloop(intro=None)

    Enters a loop that reads and execute input from user.

  color_style()

    Returns the current color map.

  color_style_names()

    Returns an iterable of all available style names.

  compile(src)

    Compiles source code and returns the (possibly modified) source and a valid code object.

  continuation_tokens(width, line_number, is_soft_wrap=False)

    Displays dots in multiline prompt

  default(line, raw_line=None)

    Implements code execution.

  emptyline()

    Called when an empty line has been entered.

  format_color(string, hide=False, force_string=False, **kwargs)

    Formats a color string using Pygments. This, therefore, returns a list of (Token, str) tuples. If force_string is set to true, though, this will return a color formatted string.

  get_lazy_ptk_kwargs()

    These are non-essential attributes for the PTK shell to start. Lazy loading these later would save some startup time.

  get_prompt_style()
  precmd(line)

    Called just before execution of line.

  print_color(string, end='\n', **kwargs)

    Prints a color string using prompt-toolkit color management.

  prompt_tokens()

    Returns a list of (token, str) tuples for the current prompt.

  push(line)

    Pushes a line onto the buffer and compiles the code in a way that enables multiline input.

  reset_buffer()

    Resets the line buffer.

  restore_tty_sanity()

    An interface for resetting the TTY stdin mode. This is highly dependent on the shell backend. For prompt-toolkit it allows to fix case when terminal lost SIGINT catching and Ctrl+C is not working after abnormal exiting.

  rprompt_tokens()

    Returns a list of (token, str) tuples for the current right prompt.

  settitle()

    Sets terminal title.

  singleline(auto_suggest=None, enable_history_search=True, multiline=True, **kwargs)

    Reads a single line of input from the shell. The store_in_history kwarg flags whether the input should be stored in PTK’s in-memory history.

  property bottom_toolbar_tokens

    Returns self._bottom_toolbar_tokens if it would yield a result

  completion_displays_to_styles = {'multi': CompleteStyle.MULTI_COLUMN, 'none': None, 'readline': CompleteStyle.READLINE_LIKE, 'single': CompleteStyle.COLUMN}
  property prompt

    Obtains the current prompt string.

  property styler

xonsh.shells.ptk_shell.disable_copy_on_deletion()

xonsh.shells.ptk_shell.tokenize_ansi(tokens)

  Checks a list of (token, str) tuples for ANSI escape sequences and extends the token list with the new formatted entries. During processing tokens are converted to `prompt_toolkit.FormattedText`. Returns a list of similar (token, str) tuples.

`completer` | Completer implementation to use with prompt_toolkit.
`formatter` | PTK specific PromptFormatter class.
`history` | History object for use with prompt_toolkit.
`key_bindings` | Key bindings for prompt_toolkit xonsh shell.
`updator` | Has classes that help updating Prompt sections using Threads.