DEV Community

Cover image for NuShell - Ceci n'est pas une |
Giuliano1993
Giuliano1993

Posted on

NuShell - Ceci n'est pas une |

Good morning everyone and happy MonDEV!

I hope you had a good weekend and that some interesting projects await you this week! At the moment, I find myself in a standby phase with personal projects, organizing ideas among things I want to pursue, things I want to study, and things I want to experiment with. I think cyclically this is somewhat the norm, and I'm dodging the "taking time off" anxiety. But this certainly doesn't put a stop to my desire to hunt for new tools and ideas to share with you every week, so let's get into the heart of today's newsletter!

We all deal with the terminal to some extent daily, whether like me you do everything from the command line or whether you prefer to work from an interface when possible. So it's essential to have a shell that is as comfortable as possible, meets our needs, and perhaps also offers some interesting features.

Today I want to talk to you about Nushell, one of those tools that I discovered 2/3 weeks ago but immediately made an impression on me for many reasons. Nushell is indeed a shell that provides a series of extremely powerful and interesting features. First of all, it's totally cross-platform. This means that you can install it on Windows, Linux, or macOS and work with it exactly the same way. The basic commands are those of bash, but they are expanded with a considerable list of additional utilities. From this premise, the major peculiarities of this shell arise: one of its most emphasized features is the extensive use of pipes (|), which, as in bash, allow you to pass the output of the previous command to the next operation, and data visualization. A basic example could be this; with the ls command on the project folder, we will get a view like this:

Screenshot-2024-03-17-200949

but maybe we are only interested in the name and size of the files, and we would like everything sorted by size: no problem! We extend our command a bit like this: ls | where type == file | select name size | sort-by size and the result will be as follows:

Screenshot-2024-03-17-201759

Interesting, isn't it? This type of functionality provides access to a lot of information quickly and easily! But there's more! Because this shell also has a feature that allows the visualization and navigation of complex structures such as JSON. An example? Let's say we want to quickly check the scripts saved under the JSON package.json key of this project. We can open the file and directly extract the key of interest like this: open package.json | get scripts then we get the following result:

Screenshot-2024-03-17-202542

"Of course," this type of operation can be performed on any JSON file; for example, if we use Nushell's http command, which allows us to make various types of http calls, to call an API, we can read the results directly in our shell! And if we want, we can filter them, allowing for convenient and rapid consultation!

nushell-ezgif-com-video-to-gif-converter

These are just three small examples of what this shell written in Rust allows. The features are many and many more, but I'll leave it up to you to discover and enjoy them; I'm currently playing around with it and it's giving me a lot of satisfaction and immediacy, now it has a fixed place among the tools I use when working! The project is Open Source, so if you want to contribute, I invite you, as always, to do so, I leave you the link to the repo here!

I hope you liked this week's tool; being a shell, it's also easier to experiment with it in our daily workflow, so I hope you'll get a chance to try it out! As always, I wish you a good Monday and a good week! Happy Coding 0_1

Top comments (0)