Xonsh – A Python-powered shell
17 comments
·February 21, 2025dang
Related:
Xonsh: Python-powered, cross-platform, Unix-gazing shell - https://news.ycombinator.com/item?id=39368586 - Feb 2024 (102 comments)
Ask HN: Does anyone use xonsh shell? - https://news.ycombinator.com/item?id=34449879 - Jan 2023 (3 comments)
Xonsh: I don't remember how to write a for loop in Bash [video] - https://news.ycombinator.com/item?id=33044772 - Oct 2022 (130 comments)
Xonsh is a Python-powered shell - https://news.ycombinator.com/item?id=30457791 - Feb 2022 (3 comments)
Xonsh is a Python-powered shell - https://news.ycombinator.com/item?id=30442016 - Feb 2022 (1 comment)
The Xonsh Python Shell - https://news.ycombinator.com/item?id=24744653 - Oct 2020 (41 comments)
Xonsh: Python-powered, cross-platform, Unix-gazing shell - https://news.ycombinator.com/item?id=17989710 - Sept 2018 (93 comments)
Xonsh: a Python-ish, BASHwards-looking shell language and command prompt - https://news.ycombinator.com/item?id=11836893 - June 2016 (2 comments)
The xonsh shell - https://news.ycombinator.com/item?id=11672023 - May 2016 (53 comments)
Xonsh, a Python-ish, Bash-compatible shell language and command prompt - https://news.ycombinator.com/item?id=9207738 - March 2015 (61 comments)
aterp
Might be interesting to folks in this thread - I'm working on a CLI tool/language which aims to let people write better scripts, more easily. It integrates well with Bash if it's needed, but lets you to avoid writing whole scripts in Bash and particularly some of the more painful aspects like arg parsing.
This page gives a bit of a preview, plus there are some links at the bottom to additional features. Still under development tho!
BeetleB
I've used xonsh as my primary shell since around 2017. It's awesome. Being able to write shell scripts in something very similar to Python is awesome. Bash scripting is the epitome of "not awesome".
brumar
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.
scottydelta
Can you talk about how is it different than writing python scripts? Or writing test code in the python console?
BeetleB
In 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
I have never tried it but I would probably prefer to use sh ( https://pypi.org/project/sh/ ) and have users install that before having to use a totally separate shell. Python is normally already there.
Neywiny
Feels 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
brumar
For 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.
Qem
What are some examples of incompatible commands?
brumar
I 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
I 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).
poincaredisk
I 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.
mharig
[dead]
I’ve been using xonsh as my daily driver for a few years now, and it’s a massive productivity booster!
Broadly speaking I’ve found that most of the reported compatibility and usability concerns in their GitHub issues have boiled down to user error, rather than any kind of a defect with the shell itself. That’s not to say there aren’t any issues, but they’re few and far between, and it’s more than solid enough for regular use. It isn’t bash, and you shouldn’t expect to execute a bash script with xonsh or use bash idioms (even though some compatibility layers exist for e.g. translating your ~/.bashrc and sourcing envvars from bash scripts).