Nushell 0.73

Nushell, or Nu for short, is a new shell that takes a modern, structured approach to your command line. 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 command line pipelines.

Today, we're releasing version 0.73 of Nu. This release includes new math commands, an interactive data viewer, and many command refinements.

Where to get it

Nu 0.73 is available as pre-built binariesopen in new window or from crates.ioopen in new window. If you have Rust installed you can install it using cargo install nu.

NOTE: The optional dataframe functionality is available by cargo install nu --features=dataframe.

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

Themes of this release / New features

PLEASE NOTE: Boolean && and || have changed

The boolean && is now and and the boolean || is now or. These were deprecated in the 0.72 release and have now been removed. Existing scripts will need to be updated to the new syntax to run in 0.73.

Experimental interactive explore command (zhiburtopen in new window)

Explore try mode

This release includes a new experimental command called explore for viewing Nu data in an interactive UI. Some things to try:

  • pipe a large table to explore (ex: ls | explore) and use explore as a fancy pager
  • run explore, then type :try and press the Enter key to enter a mode where you can run commands inside explore

explore is highly experimental and we expect it to change in the future. Please report any issues you discoveropen in new window.

New math commands (sholderbachopen in new window)

With this release we include a larger number of math commands for real valued math such as trigonometric functions and logarithms. The goal is to remove the math eval command that operates on strings instead of proper nushell expressions.

Constants

  • math pi
  • math tau
  • math e

Trigonometry and hyperbolic functions

  • math sin
  • math cos
  • math tan
  • math sinh
  • math cosh
  • math tanh
  • math arcsin
  • math arccos
  • math arctan
  • math arcsinh
  • math arccosh
  • math arctanh

Logarithms

  • math log
  • math ln
〉math pi | math cos
-1
〉math e | math ln
1
[16 8 4 2] | math log 2
[4 3 2 1]

Changes to commands with predicates (kubouchopen in new window)

any, all, skip until, skip while, take until, and take while now accept a closure instead of a row condition. For example

[[status]; [UP] [UP]] | all status == UP

becomes

[[status]; [UP] [UP]] | all {|el| $el.status == UP }

This makes them slightly more verbose but it is a part of an effort to refactor our parser to allow defining concrete grammar rules for the Nu language. Row condition is currently accepted only in the where command which becomes a parser built-in command (like use or let).

New filter command and simpler where (kubouchopen in new window)

We found the -b flag of where quite confusing and decided to remove it in favor of a new filter command. Both filter and where have similar functionality but where now only accepts a row condition and filter accepts a closure. Before:

[{a: 1} {a: 2}] | where -b {|x| $x.a > 1}

After:

[{a: 1} {a: 2}] | filter {|x| $x.a > 1}

Why is it useful to have two commands doing the same thing? Because with the filter command, you can store the closure in a variable:

let cond = {|x| $x.a > 1}
[{a: 1} {a: 2}] | filter $cond

On the other hand, where is more concise ([{a: 1} {a: 2}] | where a > 1) but you can't store its condition in a variable. The choice is yours!

New command uniq-by (raccmonteiroopen in new window)

To complement uniq which can identify unique or duplicated values in a collection or report the number of occurrences for a particular entry, we now have uniq-by. It supports filtering a table by entries appearing in a particular column.

 [[fruit day]; [apple monday] [apple friday] [Apple friday] [apple monday] [pear monday] [orange tuesday]] | uniq-by fruit
╭───┬────────┬─────────╮
 # │ fruit  │   day   │
├───┼────────┼─────────┤
 0  apple   monday  
 1  Apple   friday  
 2  pear    monday  
 3  orange  tuesday 
╰───┴────────┴─────────╯

Mutable data structures can now have their inner values mutated using = (webbedspaceopen in new window)

If a variable has been defined as mutable using the recently-added mut keyword, you can now deeply mutate its inner values using =.

 mut a = { b: 1 }
 $a.b = 2
 $a.c = 3
 $a | to nuon
{b: 2, c: 3}

This syntax enhancement was added primarily to make modifying $env.config during a normal session much easier. Now, $env.config is considered inherently mutable. You can change a single config value like so:

$env.config.table.mode = compact_double

...and it will remain in effect for the rest of the session.

More sophisticated coloring of data values using closures (webbedspaceopen in new window)

The color_config config record has new functionality: instead of specifying a single color name for all values of a given type, you may now alternatively provide a closure that dynamically computes a color for each individual value. The closure takes, as input, a single value of the given type, and must produce either a string value representing a color, or a { fg, bg, attr } record (the same as what color_config already accepts as a color value). This feature can be used to provide important visual distinctions between ranges of values in data.

Here are some examples.

filesize: {|e|
	if $e == 0b { 'dark_gray'
	} else if $e < 1mb { 'cyan_bold'
	} else { 'blue_bold' }
}

This causes all filesize values to be colored using dark_gray if they equal 0b, cyan_bold if they are less than 1mb, and blue_bold otherwise. This means that, in ls output, empty files can be more easily distinguished from non-empty ones.

bool: { if $in { 'light_cyan' } else { 'light_gray' } }

This colors true in light_cyan, and false in light_gray. This can be useful when browsing a large table of booleans.

The themes in the default config.nu file have been updated with further examples of these closures.

In certain situations (most notably, during a single ls call that isn't piped to anything else) Nushell will parallelize the execution of these closures. As such, you cannot expect that they will run in the same order as each value appears in the output data.

WARNING

Currently, closures are only supported for output values - they do not work with color settings that begin with shape_, such as shape_literal. They also do not work with the color configuration for the new explore command. Only values inside of tables are highlighted using closures.

RISC V binary release

Starting with 0.73, Nushell now provides a RISC V for Linux as part of the set of release binaries.

Breaking changes

Full changelog

Nushell

Extension

Documentation

Nu_Scripts

reedline