Search code examples
shellxonsh

How to set environment variables in .xsh file?


I want to override environment variables in my foo.xsh file like this

$FOO = "foo"

But after I call xonsh foo.xsh, $FOO is not set.

Any ideas?


Solution

  • Running xonsh foo.xsh sets $FOO in a separate session that closes when the programfoo.xsh terminates.

    If you want to persist the contents of foo.xsh in your current session, you can use source foo.xsh.