Nushell 0.17.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.

Today, we’re releasing 0.17 of Nu, the first Nu to include WebAssembly, custom keybindings, and much more.

Where to get it

Nu 0.17.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

WebAssembly support (jonathandturner) and upcoming wasm-based playground (jzaefferer, jonathandturner)

image of a wasm-based NuShell playground

Nu, now in your browser

As part of on-going cleanup and portability work, with 0.17 it’s now possible to build Nu and target WebAssembly, allowing you to run Nu in the browser and call into it from JavaScript. This is the first (experimental!) step in building towards an interactive playground and possibly more. We’re hoping to talk more about this porting process in the coming days.

If you’d like to see what we’re building, check it out.

Custom keybindings (jonathandturner)

Nushell now also supports custom keybindings. To configure your keybindings, you can add a keybindings.yml file beside your config file. You can find out the location for your system using:

> echo $nu.keybinding-path
/home/jonathan/.config/nu/keybindings.yml

You can base your custom file off this example keybindings file.

New commands

benchmark (pag4k)

The new benchmark command will time a block and output the length of time it took to run:

> benchmark { echo "hello" }
363us 528ns

str reverse (JosephTLyons)

The str reverse command will reverse the characters of a string:

> echo "hello world" | str reverse
dlrow olleh

str length (jonathandturner)

On a related note, you can now also get the length of a string.

> echo "hello world" | str length
11

str from (bailey-layzer)

In previous versions of Nu, it was difficult to format numbers for precision and digit grouping. Starting with 0.17, there’s now a new str from subcommand to help with this.

> echo 1.456123 | str from --decimals 2
1.46

> echo 1234567 | str from --group-digits
1,234,567

math stddev and math variance (amousa11)

You can now calculate standard deviation and variance in your numeric datasets:

> echo [ 1 2 3 4 5 ] | math stddev
1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573

> echo [ 1 2 3 4 5 ] | math variance
2

if (jonathandturner)

Ever want to run one block if a condition was true and another if the condition was false? Now you can!

> echo 0..5 | if $it > 3 { echo big } { echo small }
───┬───────
 0 │ small
 1 │ small
 2 │ small
 3 │ small
 4 │ big
 5 │ big
───┴───────

The keen observer might notice we’re stealthly sneaking in more commands you might use in future scripting.

split chars (jonathandturner)

To more easily work with the characters in a string, you can now split the characters into separate items:

> echo "hello" | split chars
───┬───
 0 │ h
 1 │ e
 2 │ l
 3 │ l
 4 │ o
───┴───

move column (andrasio)

Finally, you can now move columns in your table:

> ls
───┬──────────────────────────────────┬──────┬─────────┬────────────
 # │ name                             │ type │ size    │ modified
───┼──────────────────────────────────┼──────┼─────────┼────────────
 0 │ 0.bootstrap.js                   │ File │ 30.9 KB │ 1 hour ago
 1 │ 46a44c28f12d33243854.module.wasm │ File │  5.4 MB │ 1 hour ago
 2 │ bootstrap.js                     │ File │ 16.3 KB │ 1 hour ago
 3 │ index.html                       │ File │  1.4 KB │ 1 hour ago
───┴──────────────────────────────────┴──────┴─────────┴────────────

> ls | move column size --before type
───┬──────────────────────────────────┬─────────┬──────┬────────────
 # │ name                             │ size    │ type │ modified
───┼──────────────────────────────────┼─────────┼──────┼────────────
 0 │ 0.bootstrap.js                   │ 30.9 KB │ File │ 1 hour ago
 1 │ 46a44c28f12d33243854.module.wasm │  5.4 MB │ File │ 1 hour ago
 2 │ bootstrap.js                     │ 16.3 KB │ File │ 1 hour ago
 3 │ index.html                       │  1.4 KB │ File │ 1 hour ago
───┴──────────────────────────────────┴─────────┴──────┴────────────

Early draft of a new website (pontaoski)

We’re working on a refresh of our website. If you’re interested in giving it a look, we’ve got an early draft started. If you’d like to help us with the design, reach out over github or discord.

Command improvements

Bug fixes, tests and more (philip-peterson, JosephTLyons, u5surf, thegedge, arashout, jonathandturner)

Parsing now has more test coverage. Internal code cleanups. Command description copy paste issues fixed. Ensure that the MaybeTextCodec gets properly cleared. Fix documentation to renamed subcommands and str to-int. Internally more commands were moved to process their streams lazily. We can now generate documentation from reading the built-in docs on each command.

Breaking changes

BSON and Sqlite move to plugins (jonathandturner)

As part of the portability work, we’ve moved the from bson, to bson, from sqlite and to sqlite out of internal commands and into plugins. The functionality should remain largely unchanged, with the only difference being that you’ll need to install these plugins for this functionality.

Command renames

Looking forward

Just when we think we’ll slow down a little, we’re surprised by the amount of community feedback and help. This release covered nearly 4(!) pages of pull requests. Not bad for three weeks for work!

There’s some parser work coming up to help continue removing roadblocks to using Nu as a scripting language, improving completions, and generally continuing to polish Nu.