Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
https://github.com/xonsh/xonsh/wiki/Cheatsheet
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.
-
source
sources in a xonsh script.source-bash
sources in a Bash script.https://xon.sh/aliases.html#source-bash
https://github.com/xonsh/xonsh/issues/2978
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.system
orsubprocess.run
-
wrap 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
https://github.com/xonsh/xonsh/issues/1477#event-2481368935
References
Bash to Xonsh Translation GuideĀ¶
Updating and customizing xonsh
https://github.com/xonsh/xonsh/issues/1477#event-2481368935
https://stackoverflow.com/questions/39724184/how-to-write-a-multi-command-alias-in-xonsh/39761905#39761905