Core Events

The following events are defined by xonsh itself.

on_chdir on_exit on_post_cmdloop
on_post_init on_post_rc on_postcommand
on_pre_cmdloop on_pre_rc on_precommand
on_transform_command    

Listing

on_chdir(olddir: str, newdir: str) -> None

Fires when the current directory is changed for any reason.


on_exit() -> None

Fired after all commands have been executed, before tear-down occurs.

NOTE: All the caveats of the atexit module also apply to this event.


on_post_cmdloop() -> None

Fired just after the command loop finishes, if it is.

NOTE: All the caveats of the atexit module also apply to this event.


on_post_init() -> None

Fired after all initialization is finished and we’re ready to do work.

NOTE: This is fired before the wizard is automatically started.


on_post_rc() -> None

Fired just after rc files are loaded, if they are.


on_postcommand(cmd: str, rtn: int, out: str or None, ts: list) -> None

Fires just after a command is executed. The arguments are the same as history.


on_pre_cmdloop() -> None

Fired just before the command loop is started, if it is.


on_pre_rc() -> None

Fired just before rc files are loaded, if they are.


on_precommand(cmd: str) -> None

Fires just before a command is executed.


on_transform_command(cmd: str) -> str

Fired to request xontribs to transform a command line. Return the transformed command, or the same command if no transformaiton occurs. Only done for interactive sessions.

This may be fired multiple times per command, with other transformers input or output, so design any handlers for this carefully.