7 ms·
I would not advise to replace your interactive shell with it as it's a pain when you stumble upon uncompatible commands, but writing shell scripts with xonsh is
by brumar 2y ago
I would not advise to replace your interactive shell with it as it's a pain when you stumble upon uncompatible commands, but writing shell scripts with xonsh is a wonderful experience.
- Qem 2y agoWhat are some examples of incompatible commands?
- brumar 2y agoI don't remember exactly why and how some shell scripts refused to run, but on top of my head I think 'alias' was not working and 'sudo !!' too.
- BeetleB 2y agoI hope you're not trying to source regular Bash scripts without using source-bash. I've used xonsh as my primary shell for many years now. The Bash compatibility was poor initially, but they fixed most/all the issues, and source-bash just works. I use Gentoo, and don't actually use sudo, so I can't comment on that (I just su into root).
- brumar 2y agoInteresting! I think I never tried to update xonsh in 7 years or so.
- poincaredisk 2y agoI use fish, so it's not a problem for me. When I tried it 4 years ago it's was a bit unstable, which made me switch back to fish. Also fish is much more polished and user friendly out of the box.
- scottydelta 2y agoCan you talk about how is it different than writing python scripts? Or writing test code in the python console?
- Neywiny 2y agoFeels like the only benefit is not having to write os.system(). Though maybe including shell scripts (like build environment setup stuff from other software) for more complicated commands? I may give this a try for a bit to find out
- shlomo_z 2y agoos.system doesn't actually change your environment: >>> os.getcwd() 'C:\\Users\\Admin\\Downloads' >>> os.system("cd Video") 0 >>> os.getcwd() 'C:\\Users\\Admin\\Downloads' >>>
- timonoko 2y agoThis the perfection, why would you want anything more? import os def sh(x): return os.popen(x).read().split("\n")
- brumar 2y agoFor me it shines when you need to write shell scripts but you prefer do some parts in python. As another commenter wrote os.system or calling the subprocess module works too, but I find it less satisfying.
- BeetleB 2y agoIn a xonsh script, you can have regular statements like "cd", "ls", and pretty much everything. It's just like Bash scripting, except in Python. You can mix and match Python statements with regular shell commands.
- echoangle 2y agoI have never tried it but I would probably prefer to use sh ( https://pypi.org/project/sh/ https://pypi.org/project/sh/ ) and have users install that before having to use a totally separate shell. Python is normally already there.