These recent days I have been browsing the Internet, looking for useful information related to Shell scripting. In order to update the code of a useful little software tool that I created a little over a decade ago. Application that at the time, was called Linux Post Install – Bicentennial Script (LPI-SB), and was generated only with Bash-based command prompts. And in the middle of that search I have come across an interesting utility or program called "Xonsh".
For those who have never heard of this application, it is worth mentioning that it is a great tool for terminal software offering a shell language and a Cross-platform command prompt That works with Python.
And as usual, before we dive into today's topic of Terminal tools and uses, and more specifically about the useful application called "Xonsh", we will leave for those interested the following links to some previous related posts. In such a way that they can easily explore them, if necessary, after finishing reading this publication:
“Shell Scripting is the technique (skill) of designing and creating Script (task automation file) through a Shell (preferably) of an Operating System, or a Text Editor (Graphic or Terminal). This is a type of programming language that is generally interpreted. That is, while most programs are compiled (encrypted), because they are permanently converted to a specific (special) code before they can be executed (compilation process), a shell script remains in its original form (its code source in text form) and are interpreted command by command each time they are executed". Shell, Bash and Scripts: All about Shell Scripting
Table of Contents
Xonsh: Shell for Bash, Python and more
What is Xonsh?
According to his Official website, the application "Xonsh" It is briefly described as follows:
"It is a shell powered by Python. A cross-platform shell language and command prompt powered by Python. The language is a superset of Python 3.6+ with some additional shells that you're used to from Bash and Python. It works on all major systems including Linux, OSX and Windows. Xonsh is intended for daily use by experts and novices".
However, they later add that with her:
"Any terminal user can easily mix Python and Shell commands (such as Bash) in a powerful and simplified command line approach".
Which, in simpler words, means that when executing "Xonsh" we are offered a Shell or terminal environment where we can run both simple commands and Complex Bash Shell Command Prompts and Python. Which can be extremely useful, both for SysAdmin and Devs, as for terminal enthusiasts and beginners, either to learn or to start working.
Currently, "Xonsh" goes for his last version of number 0.11.0, released the day 17/11/21. And it can be installed in many ways, for example, by console, in a traditional way with the usual package manager used in each GNU/Linux Distro, as by the manager python pip, or via an AppImage file or using Docker.
Among its general characteristics or functions has the following:
- Allows you to combine (Bash) Shell commands with Python or vice versa.
- It allows the use of third-party extensions, xontributions or xontribs, which are nothing more than a set of tools and conventions to extend the functionality of xonsh.
- It offers a robust interface in terms of history management, since it creates history files with a rich structure and metadata and an API to interact with them.
- It includes powerful prompt customization through tab completion, key bindings, and customizable color styles built in by default.
While, in this latest current version new features were included, such as:
- Addition of the union of the CTRL-Right keys to complete a single word of autosuggestion.
- Display of the type and description of environment variables upon completion.
- Improved pip/xpip completer.
- Addition of the CTRL-Backspace key to delete a single word via $XONSH_CTRL_BKSPC_DELETION.
In our case, after installed with the command
«sudo apt install xonsh» and the next
«sudo pip3 install prompt_toolkit», we were able to start executing it and typing Bash and Python commands in only one Shell, as shown below:
Running the Xonsh Shell
Bash Command Examples
Python command examples
Finally, to explore more articles on Shell Scripting in FromLinux you can click the following link. And if you are curious to see the application that I am developing with pure bashI recommend you go to me YouTube channel and watch the videos about Linux Post Install – Automated Optimization Script (LPI-SOA).
In summary, "Xonsh" it's a great tool terminal software (CLI). What's more, it is extremely useful for those who love make scripts or practice Shell Scripting, not only about Bash but about Python, among others (Zsh, Fish, and Plumbum). Therefore, we hope that interesting tool continue to develop for the benefit of those who are passionate GNU / Linux users, and Terminal.
We hope that this publication is very useful for the entire
«Comunidad de Software Libre, Código Abierto y GNU/Linux». And don't forget to comment on it below, and share it with others on your favorite websites, channels, groups or communities of social networks or messaging systems. Finally, visit our home page at «FromLinux» to explore more news, and join our official channel Telegram from DesdeLinux.