First Impressions of Xonsh


Posted by alex


I first heard of Xonsh at PyCaribbean in February. Since then, I had been a little bit interested, but the lack of a Debian package prevented me from installing it and trying it out.

Then came PyCon 2016. Xonsh's creator, Anthony Scopatz, gave a talk about Xonsh which showed off a multitude of exciting features. I was then motivated to try it out myself. Now follow my first impressions of Xonsh.

Xonsh is a shell that is supposed to bridge the gap between being a Python interpreter and a bash shell. It does this by introducing special syntax for writing Python and calling out to bash processes standard Linux commands and programs. For example, you can retrieve some json data with curl, and then parse it using json.loads() from Python.

This has powerful implications for the way a python programmer interacts with the shell. The shell allows you to express ideas in whichever way occurs to you first and feels very natural to use.

Of course, mixing Python and Linux commands is an abomination in terms of maintainability, so I would never advocate actually writing Xonsh scripts and saving them for any reason. If you're at the point of needing a script, you might as well reach for full Python or full collaborators probably aren't usaing Xonsh yet.

Installing Xonsh

The best way to install anything on a Linux distribution is via your distribution's package manager. On my system, Debian, a Xonsh package is not yet available, so I had to install it manually.

Edit: A Debian package now exists! tells you to run pip install xonsh to install it, but I'll go a little bit more in depth on how I did it.

  • Create a virtualenv

    I use Fish as my default shell, with virtualfish as a replacement
    for virtualenvwrapper. So I do vf new xonsh to create a new

  • Install xonsh (and dependencies)

    Here we just follow the documentation. pip install xonsh

  • Create an alias in your current shell

    Since I use Xonsh as a back up shell, I have the alias x in Fish
    so that it is easy for me to drop into Xonsh when I want to.

Using Xonsh

There is a tutorial for how to use Xonsh:

And here is the talk that motivated me to go out and try it:

Final Thoughts

I don't think Xonsh is ready for prime-time yet. Its start up speed is somewhere above one second, which is just too slow for a shell. I wasn't able to find any good resources about Virtualenv support. (Edit: Xonsh has built in Virtualenv support) It's still pretty buggy. But it has tremendous promise, and I'm excited to see where it is 6 months from now!


Return to Articles & Guides