Xonsh Shell Combines the Best of Bash Shell and Python in Linux Terminal

If you are primarily into Python development on Linux, Xonsh shell could be an addition to your toolkit.
Warp Terminal

Which is the most popular shell? I guess you’ll say bash or perhaps zsh and you are right about that.

There are several shells available for UNIX and Linux systems. bash, ksh, zsh, fish and more.

Recently, I came across another shell which offers a unique twist of combining Python and bash.

Xonsh shell for the Python loving Linux users

Xonsh is a Python-powered, cross-platform, shell language and command prompt.

It combines Python and bash shell in a way that you can run Python commands directly in the shell. You can even combine Python and shell commands.

xonsh shell combines python bash

Sounds good? It may sound even better if you are a Python programmer.

Installing Xonsh shell on Linux

There are several ways you can install Xonsh shell on your system.

You can install it from your distribution’s package manager (it is available in the repositories of major distributions).

On Ubuntu and Debian, you may try:

sudo apt install xonsh

Since it is essentially a Python application, you always have the option to use Pip (if you have pip installed on your system). Conda can also be used for installing Xonsh. There is also an AppImage available along with a Docker image.

You may choose whichever installation method you prefer.

Experiencing the Xonsh shell

If you are new to the multiple shell concept or the terminal, I suggest reading my article on terminal introduction. It will help clear numerous things for the Linux beginners.

Quick recap. Your terminal runs a default shell (usually bash shell). If you have other shells installed on your system, you can easily switch the shells.

To enter the Xonsh shell, simply run this command:

xonsh shell

It advises you to run a wizard and create a customized rc file for Xonsh shell. It’s optional and you may do it later as well.

You can start feeling a bit of difference as soon as you start using it.

As you start typing a command, Xonsh shell automatically suggests the last matching command from the history. You can press the right arrow key to confirm it and use the auto suggested command. You can press the up and down arrow key to go back to other matching commands from the history.

auto suggestions from history in xonsh shell
Xonsh shell automatically suggests last matching command from the history as you type

That’s not it. The tab completion is interactive here. Start typing the command and press tab and it shows a dropdown kind of interactive menu. From here, you can choose between the available commands.

tab completion xonsh shell
Tab completion in Xonsh shell

You can combine the Python and bash commands and run them directly in the shell.

If you are into terminal customization, you can spend some time and effort to customize tab completion, key bindings and color styles as per your preference.

It also has a user generated plugin systems called Xontrib and you can use them to extend the functionality of the Xonsh shell.

If you are a terminal lover and interested in learning more on it, you can go through its extensive documentation system.

In the end…

Most users stick with the default bash shell and there is nothing wrong with it. Some developers and sysadmins opt for Zsh for its additional features. Xonsh focuses entirely on Python and it may attract Python users. For the rest of us, bash is good enough.

Have you ever used Xonsh or some other shell? Why do you use it instead of bash? The comment section is all yours.

About the author
Abhishek Prakash

Abhishek Prakash

Created It's FOSS 11 years ago to share my Linux adventures. Have a Master's degree in Engineering and years of IT industry experience. Huge fan of Agatha Christie detective mysteries 🕵️‍♂️


Making You a Better Linux User


Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to It's FOSS.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.