diff --git a/docs/xonshrc.rst b/docs/xonshrc.rst index dfb22591f..caed37704 100644 --- a/docs/xonshrc.rst +++ b/docs/xonshrc.rst @@ -25,6 +25,7 @@ In addition: * Use ``xonsh --rc snail.xsh`` to run only a certain control file. * Use ``xonsh -i script.xsh`` to run xonsh in interactive mode with loading all possible control files. * Use ``xonsh --rc rc1.xsh rc2.xsh -- script.xsh`` to run scripts with multiple control files. +* You can create autoloadable `xontrib `_ as alternative to run control file and reuse it as python package. The options set per user override settings in the system-wide control file. diff --git a/news/norc_noautoload.rst b/news/norc_noautoload.rst new file mode 100644 index 000000000..453d690bc --- /dev/null +++ b/news/norc_noautoload.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* xontrib: Do not autoload xontribs in ``xonsh --no-rc`` mode. + +**Fixed:** + +* + +**Security:** + +* diff --git a/xonsh/environ.py b/xonsh/environ.py index 9ff7121d8..e155f75b0 100644 --- a/xonsh/environ.py +++ b/xonsh/environ.py @@ -1347,8 +1347,9 @@ class InterpreterSetting(Xettings): class XontribSetting(Xettings): """Xontrib Settings""" - XONTRIBS_AUTOLOAD_DISABLED = Var( + XONTRIBS_AUTOLOAD_DISABLED = Var.with_default( default=False, + type_str="bool", doc="""\ Controls auto-loading behaviour of xontrib packages at the startup. * Set this to ``True`` to disable autoloading completely. diff --git a/xonsh/main.py b/xonsh/main.py index 594033dbd..2823d86de 100644 --- a/xonsh/main.py +++ b/xonsh/main.py @@ -361,8 +361,10 @@ def start_services(shell_kwargs, args, pre_env=None): scriptcache=shell_kwargs.get("scriptcache", True), cacheall=shell_kwargs.get("cacheall", False), ) - XSH.load(ctx=ctx, execer=execer, inherit_env=shell_kwargs.get("inherit_env", True)) events.on_timingprobe.fire(name="post_execer_init") + events.on_timingprobe.fire(name="pre_xonsh_session_load") + XSH.load(ctx=ctx, execer=execer, inherit_env=shell_kwargs.get("inherit_env", True)) + events.on_timingprobe.fire(name="post_xonsh_session_load") install_import_hooks(execer) @@ -370,7 +372,8 @@ def start_services(shell_kwargs, args, pre_env=None): for k, v in pre_env.items(): env[k] = v - _autoload_xontribs(env) + if not shell_kwargs.get("norc"): + _autoload_xontribs(env) _load_rc_files(shell_kwargs, args, env, execer, ctx) # create shell XSH.shell = Shell(execer=execer, **shell_kwargs)