Nushell 0.13.0

Nushell, or Nu for short, is a new shell that takes a modern, structured approach to your commandline. It works seamlessly with the data from your filesystem, operating system, and a growing number of file formats to make it easy to build powerful commandline pipelines.

We’re excited to release version 0.13.0 of Nu! This is by far one the the biggest releases, yet. Let’s dive in!

Where to get it

Nu 0.13.0 is available as pre-built binaries or from crates.io. If you have Rust installed you can install it using cargo install nu .

If you want more goodies, you can install cargo install nu --features=stable .

As part of this release, we also publish a set of plugins you can install and use with Nu. To install, use cargo install nu_plugin_<plugin name> .

What’s New

Aliases (jonathandturner)

Yes, it’s true. Nu now supports aliases so that those long pipelines now have new life as concise, reusable commands.

> alias myecho [msg] { echo $msg } > myecho "hello world!" hello world!

The alias has a name, a list of optional parameters, and the block that will execute. This block can refer to the parameters using their variable names.

Startup commands (jonathandturner)

With aliases, it’s helpful to be able to start up Nu with your favorite aliases ready to go. To this end, we’ve now added the startup config variable. Adding a table of strings to this config variable enables you to run all of these commands as Nu starts up.

> config --set [startup ["alias myecho [msg] { echo $msg }"]]

You can read more about setting config variables in the book

Multi-dot paths (quebin31)

In some shells, you can use multiple dots to mean go back even more directories. In addition to the common .. , to go back to the previous directory, you can now also use ... to go back two directories, .... to go back three, and so on.

Semicolon support (jonathandturner)

A long standing annoyance when using Nu day in and day out is that you can’t compose two different pipelines together. Sometimes you want to run a build, and then run the output of the build if it succeeds.

In Bash, you might do something like this:

> make && ./run/my/app

If make succeeds, then your app runs. We’re introducing the ‘;’ separator which does this (beware bash users that this ‘;’ will stop if the left-hand fails). You can write the above bash line as this in Nu 0.13.0:

> make; ./run/my/app

Note that commands that you may be used to printing to the terminal when you run them directly may not print anything when used on the left-hand side of the ; . This is because the data comes out and, being structured, it just gets consumed before it’s viewed. If you prefer to see the output of a command on the left of the ; , you can pass it through autoview to do this for you:

> ls | autoview ; echo "done"

Math operations (jonathandturner)

Wish you had a calculator or want to do a quick computation on something in your table? With 0.13.0, you can now switch into “math mode” and do a quick calculation. To switch into math mode, use the = operator as the command name.

> = 3 + 4 7

You can use this in pipelines as well, do something like:

ls | get size | = $it + 1mb

It doesn’t end there. Not only are the basic +, -, *, and / available, but you can use these new operators:

checking if a value is in a member of the given table with in:

> = a in: [a b c] true > = d in: [a b c] false

&& and || to create compound comparisons

> ls | where name > 'f' && size > 1kb

Parens to allow grouping

= (1 + 2) * (3 + 4) 21

New parser logic (jonathandturner)

Early in this release cycle, we began experimenting with different ways we could write the parser going forward. Being able to parse commands, where each command could dictate how the parser works for that command, is a special challenge of how Nu works. After a bit of experimenting, we found a way forward that quickly seemed to fix some of the long-standing bugs. Not only this, but it opened up the way for a set of new features.

If you find issues with this new parser logic where code that used to work no longer works, please let us know. This will help us work out any issues as we build new features on it.

External improvements (thegedge, jonathandturner)

With 0.13.0, we’re taking a big step to making externals work in a way much more in-line with how internals work. This allows us to provide better support for varibles, column paths, coloring, error handling, and more.

Many bugfixes and improvements (DrSensor, thegedge, quebin31, jonathandturenr, avendesa, and more)

Better docker publish for each release (DrSensor)

Correctly delete symlinks (thegedge)

Better path canonicalization (quebin31)

Simplify cp and allow recursive copying (quebin31)

and allow recursive copying (quebin31) Make trash optional (jonathandturner)

Add support for $true and $false (jonathandturner)

and (jonathandturner) Fixes for a few path and where -related issues (avendesa)

-related issues (avendesa) Plus fixes in our dependencies, many thanks to those crate owners!

Pipeline blocks and the new each command (jonathandturner)

Starting with 0.13.0, blocks can now contain pipelines (including ; -separated multiple pipeline blocks). This allowed us to create the first command to take advantage of this: each . The new each command will run over each row in a table and do something for each. For example, let’s say you wanted to convert each row of a table to separate JSON, rather than converting the whole table:

> ls | each { to-json }

Breaking changes

With the math operations above, we’re now changing the default type of syntax in a block. Where as before, the expanded version of where was:

(0.12.0)

> ls | where { $it.size > 10kb }

(0.13.0)

> ls | where { = $it.size > 10kb }

This is because blocks are now pipelines by default, so you need the extra = to switch into the math mode, which allows using the comparison operator > .

You can also still use the shorthand versions of these comparisons:

> ls | where size > 10kb > ls | where $it.size > 10kb

Looking forward

With 0.13.0, we’ve landed some important features that fill in gaps for using Nu as your daily driver, and we’re excited to hear from our users. Looking forward, there’s a lot of polish we’d like to put on these new features, including updating the book, cleaning up the code, writing more test cases, and fixing some of our bug backlog. This will also give us time to “kick the tires” on these new features as well, using them in our day-to-day work. We’re currently planning for the following release to be more focused on “polish”. After this, of course, there are many more features to come!