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

# xonsh.main

The main xonsh script.

class xonsh.main.XonshMode(*values)
  interactive = 3
  script_from_file = 1
  script_from_stdin = 2
  single_command = 0

xonsh.main.get_setproctitle()

  Proxy function for loading process title

xonsh.main.main(argv=None)

xonsh.main.main_context(argv=None)

  Generator that runs pre- and post-main() functions. This has two iterations. The first yields the shell. The second returns None but cleans up the shell.

xonsh.main.main_xonsh(args)

  Main entry point for xonsh cli.

xonsh.main.path_argument(s)

  Return a path only if the path is actually legal (file or directory)

  This is very similar to argparse.FileType, except that it doesn’t return an open file handle, but rather simply validates the path.

xonsh.main.postmain(args=None)

  Teardown for main xonsh entry point, accepts parsed arguments.

xonsh.main.premain(argv=None)

  Setup for main xonsh entry point. Returns parsed arguments.

xonsh.main.setup(ctx=None, shell_type='none', env=(('RAISE_SUBPROC_ERROR', True),), aliases=(), xontribs=(), threadable_predictors=())

  Starts up a new xonsh shell. Calling this in function in another packages `__init__.py` will allow xonsh to be fully used in the package in headless or headed mode. This function is primarily indended to make starting up xonsh for 3rd party packages easier.

  Here is example of using this at the top of an `__init__.py`:

      from xonsh.main import setup
      setup()
      del setup

  Parameters:
    ctx dict-like or None, optional

      The xonsh context to start with. If None, an empty dictionary is provided.

    shell_type str, optional

      The type of shell to start. By default this is ‘none’, indicating we should start in headless mode.

    env dict-like, optional

      Environment to update the current environment with after the shell has been initialized.

    aliases dict-like, optional

      Aliases to add after the shell has been initialized.

    xontribs iterable of str, optional

      Xontrib names to load.

    threadable_predictors dict-like, optional

      Threadable predictors to start up with. These overide the defaults.

xonsh.main.start_services(shell_kwargs, args, pre_env=None)

  Starts up the essential services in the proper order. This returns the environment instance as a convenience.