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

# xonsh.shells.base_shell

The base class for xonsh shell

class xonsh.shells.base_shell.BaseShell(execer, ctx, **kwargs)

  The xonsh shell.

  Notes

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

  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.

  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 the colors in a string. `BaseShell`’s default implementation of this method uses colors based on ANSI color codes.

  precmd(line)

    Called just before execution of line.

  print_color(string, hide=False, **kwargs)

    Prints a string in color. This base implementation’s colors are based on ANSI color codes if a string was given as input. If a list of token pairs is given, it will color based on pygments, if available. If pygments is not available, it will print a colorless string.

  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. Also it is mostly optional since it only affects ^Z backgrounding behaviour.

  settitle()

    Sets terminal title.

  singleline(**kwargs)

    Reads a single line of input from the shell.

  property prompt

    Obtains the current prompt string.

  property styler

class xonsh.shells.base_shell.Tee(buffer=None, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)

  Class that merges tee’d stdout and stderr into a single stream.

  This represents what a user would actually see on the command line. This class has the same interface as io.TextIOWrapper, except that the buffer is optional.

  close()

    Closes the buffer as well as the stdout and stderr tees.

  getvalue()

    Gets the current contents of the in-memory buffer.

  property line_buffering