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

# xonsh.shell

The xonsh shell

class xonsh.shell.Shell(execer, ctx=None, shell_type=None, history_backend=None, **kwargs)

  Main xonsh shell.

  Initializes execution environment and decides if prompt_toolkit or readline version of shell should be used.

  Parameters:
    execer Execer

      An execer instance capable of running xonsh code.

    ctx Mapping, optional

      The execution context for the shell (e.g. the globals namespace). If none, this is computed by loading the rc files. If not None, this no additional context is computed and this is used directly.

    shell_type str, optional

      The shell type to start, such as ‘readline’, ‘prompt_toolkit1’, or ‘random’.

    history_backend str, optional

      The name of the history backend to use.

  static choose_shell_type(init_shell_type=None, env=None)
  static construct_shell_cls(backend, **kwargs)

    Construct the history backend object.

  shell_type_aliases = {'b': 'best', 'best': 'best', 'd': 'dumb', 'dumb': 'dumb', 'prompt-toolkit': 'prompt_toolkit', 'prompt_toolkit': 'prompt_toolkit', 'ptk': 'prompt_toolkit', 'rand': 'random', 'random': 'random', 'readline': 'readline', 'rl': 'readline'}

xonsh.shell.deindent(src)

  Remove leading indentation from `src` before compilation.

  Applies `textwrap.dedent` to strip the common leading whitespace from every line. If the first line ends with a line-continuation backslash and still begins with whitespace after dedent (paste of a subproc command where line 1 was indented deeper than the continuation line), also `lstrip` the source so the first line is flush-left.

xonsh.shell.transform_command(src, show_diff=True)

  Returns the results of firing the precommand handles.