How to source another file in xonsh?

74 Views Asked by At

In posix shells it is . filepath and in bash you can do source filepath.

What is the equivalent in xonsh?

1

There are 1 best solutions below

0
Qyriad On BEST ANSWER

You can source a xonsh file by path with the source builtin command, e.g.:

@ source ~/.config/xonsh/rc.xsh

will re-source a xonshrc in that location.

You can also source .xsh files with import (docs). This requires the xonsh file to be in a directory that is in sys.path, or in the current directory. The above example with import instead looks like this:

@ cd ~/.config/xonsh
@ from rc import *

Finally, if you want to source files written for other shells, there is also source-foreign, and its shortcut aliases like source-bash, which will pull in any changes to environment variables and aliases.