# 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 (opens new window) or from crates.io (opens new window). 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 (opens new window).

# 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

You can base your custom file off this example keybindings file (opens new window).

# 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

# 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

> echo 1234567 | str from --group-digits

# 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

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

# 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 (opens new window). If you'd like to help us with the design, reach out over github or discord.

# Command improvements

  • sort-by can now sort with case-insensitivity (JosephTLyons)
  • alias of externals should now be improved (bailey-layzer)
  • history should be able to correctly store more than 100 rows now (fdncred)
  • to html will now output pretty hex when given a binary it doesn't recognize (jonathandturner), and now has color themes (fdncred)
  • uniq can now also work with simple values (k-brk)
  • Completions now have their own abstraction, so we can more easily improve them in the future (thegedge)
  • table now prints column numbers a bit more orderly way (Porges)
  • str made parsing more strict, to let the user know if there were parsing errors (andrasio)
  • group-by can now take a block that allows for deep keying for grouping (andrasio)
  • autoenv (directory-specific environments) can now run commands on entry/exit (samhedin)
  • str trim can now take an optional character to trim (bailey-layzer)
  • duration pretty-print is now easier to read (jonathandturner), durations are also now stored as nanoseconds internally (pag4k)
  • str substring supports more argument types now (andrasio)
  • completions for filepaths should now work in more cases (almindor)
  • rm now gives nicer output (arashout)
  • ls -f will now do a better job of keeping the tables aligned (arashout)
  • general parser improvements (philip-peterson, jonathandturner)
  • each can now number the outputs it creates, allowing for enumeration (jonathandturner)

# 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

  • calc is now math eval to join the math subcommand family (coolshaurya)
  • keep-until and keep-while are now subcommands: keep until and keep while (k-brk)
  • skip-while and skip-until are also now subcommands: skip while and skip until (andrasio)
  • config is now split into subcommands based on the command flag, eg) config set, config get, etc. (ritobanrc, jonathandturner)

# 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.