Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
https://
Tricks and Traps¶
While
$()in xonsh works similar to$()in (all variants of) shell, it cannot be used in the middle of argument of a shell command. Please refer to issue 1022 and issue 3290 for more details. My suggestion is to stick to xonsh as much as possible (as Python is much better than shell) unless you encounter the above issues.xonsh messes up console flush sometimes. Please refer to issue 3320 for more details.
sourcesources in a xonsh script.source-bashsources in a Bash script.
Python Evaluation¶
Python Evalation with @()¶
The code below prints 1 2 3 in xonsh.
x = [1, 2, 3]
echo @(x)Python Evalation with f-string.¶
The Python variales are casted to string directly.
For example,
the code below prints [1, 2, 3] in xonsh.
x = [1, 2, 3]
echo f'{x}'Force (Shell) Subprocess¶
use
os.systemorsubprocess.runwrap the command in
$(). Notice that$()cannot be used in the middle of arguments currently.wrap the command in
$[]for some commands, you just need to put part of it into single/double quotes. For example, xonsh fails to recognize
pip3 install dask[complete]as a shell command while it recognizepip3 install "dask[complete]"as a shell command.
Background Mode for Subprocess¶
References¶
Bash to Xonsh Translation Guide¶