41 comments

[ 0.22 ms ] story [ 74.6 ms ] thread
I love that first paragraph! I have no idea what Nu is going in, but all it took was 2 sentences and I'm up to speed.

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

So often there's link to some new release of something and I have no idea what it does. I'm not sure why more projects don't start with an explanation of what that project is/does!

(comment deleted)
This is a massive release; congratulations to the Nu team for replacing the engine, line editor, and more.

Nu isn't quite 1.0 yet but this is the first release I can see using as my daily driver. There are a few rough edges and things aren't 100% stable yet, but I'm really impressed by the overall level of polish. Using Nu is like a glimpse into a future where string parsing is largely a thing of the past.

I've been helping out a bit with the documentation; if you have questions about getting started with Nu or if anything in the docs is unclear, let me know! https://www.nushell.sh/book/

How to disable hints?
What hints are you looking to disable?
I am PowerShell user for decade+ and this is the first time I am actually excited about Nushell. This release is awesome.
Been using this for a while now. It's very good, well designed and the right way (imo) to modernise the shell.

Bringing datastructures to the shell environment (instead of everything being strings) is just the right thing to do, and I've been personally interested in making binaries that can natively input/output these data structures.

big thanks to the team, this stuff is cool.

Have they found the right way to be inclusive of and handling old-style tools that only in/output text? That's usually a deciding factor in how improvements and new systems gain traction - that they are possible to introduce gradually and they deal with all existing programs.
I think it's pretty good.

It's easy to pipe text-speaking tools into Nu pipelines, and there's a built-in `lines` command that will split line-break-delimited text into a list of strings. From there you can use lots of tools to operate on each line.

Going from Nu data structures to raw lines of text is a little clumsier (`str collect (char newline)` IIRC) but I think that will get improved soon enough.

There's also a handy `detect columns` command that does a pretty good job of automatically converting text tables from old *nix/Windows tools into Nu tables.

You need to write a plugin in rust. The builtin scripting language isn't that good.
In the article, they show how you can use any language to write a plugin.
No. Plugins are just executables that communicate with Nu over stdin/stdout using JSON or Cap’n Proto; they can be written in any language.
Writing a plugin is an example of Nu not solving the problem in general - maybe you misunderstood my question
Does anyone use this with nix/home-manager? I'd love to try this, but it looks like there would be struggles sourcing the nix daemon?
I'm not sure about home-manager, but I've been using Nushell as my daily-driver with nix on Macos for almost a month now. This new release will make the integration with nix even easier.

Basically, instead of sourcing the nix.sh script in your shell config file (.bashrc or equivalent), you manually add the two significant nix directories to your path in the Nu config file.

The Nix Manual[1] explains what the nix.sh script does: "To use Nix, some environment variables should be set. In particular, PATH should contain the directories prefix/bin and ~/.nix-profile/bin." So it's as easy as adding those to your path in the config file, which in Nu looks like `let-env PATH = [...other path elements, "path/to/home/dir/.nix-profile/bin", "/nix/var/nix/profiles/default/bin"]`.

[1] https://nixos.org/manual/nix/stable/installation/env-variabl...

Thanks! I'll definitely check out Nu tomorrow.
I love the concept but I can't see myself using this regularly unless they really hammer out a lot more stdlib. This might be a lot less noise than powershell but powershell still has all of .NET accessible to its scripts.
I wonder if nushell could also use dotnet in a similar way, considering PowerShell has already done the work.
I feel like I'm the main audience for PowerShell (.NET is my primary tech stack) but I could never get into it. Using .NET in PowerShell always felt really awkward+slow (like, the one time I embedded some C# in my profile it made PowerShell startup way slower). Do you have any tips for using .NET from PowerShell?
Not sure what is your problem here. The code is almost the same as in C# most of the time (not embedding C#, writing equivalent pwsh code).

On the other hand, in 10+ years using it I had to use C# inside no more then couple of times. Accessing other stuff via native calls (such as [DateTime]::Now or [string]::IsEmptyOrWhiteSpace) is more common.

You should not be using the Powershell that comes bundled with Windows. It's slow and only updated with major system upgrades. Install the open source version: `dotnet install powershell`.

Having said that, Powershell suffers from the same problem as .NET: slow startup. It's improved massively in the last few versions and I think it will get even faster once it's built using NativeAOT in .NET 7. But it can also never be as fast as .NET, since it's interpreted. So there's that.

> Powershell suffers from the same problem as .NET: slow startup

This is a popular belief but I don't think it's true that .NET has slow startup. The CLR starts up in milliseconds, the JIT's first-tier compilation is crazy fast, and if you need to it's trivial to ship precompiled code using ReadyToRun. I don't know what makes PowerShell so slow to start up but I wouldn't blame it on .NET without more evidence.

PowerShell is not the fastest beast around but its not slow as some people try to portray it regularly. In my experience it usually boils down to:

1. Windows defender (it slows down any file access by the factor of 10 at least)

2. Virtual machine / VDI (I had 5-10s startup time on my VDI)

3. Slow modules to load (particularly those that source ps1 files instead having everything in psm1, but this is easy to diagnose as you can start it without modules)

Other then that, I never had startup time longer then 1s with bunch of modules. While that is not ultra fast, its not slow either. I must have been using it on thousand+ different machines and OSes.

Furthermore, its incomparable to bash, since once started, you rarely have to load any external processes. As an example to get something from REST API and sort and convert to CSV you can use only pwsh cmdlets, while in bash you need to use curl, jq, sort, awk etc. just for this one command. So such scripts must be slower, particularly on Windows where processes are more expensive.

Can anyone who has used nushell for a while comment on pros/cons?
I'm very curious to hear from the folks who have used Nu as a daily driver. Besides the initial relearning costs and the rough edges to be expected from work-in-progress software, have you run into downsides compared to shells like Bash or Fish?
I haven't switched to it as my daily driver (yet) because of some downsides. Several are addressed in this release, but there are still a few features that aren't there yet including:

- no support for background tasks, or resummoning stopped processes

- while completion was added in 0.60, it doesn't look quite as featureful as zsh completion, and of course it doesn't have as many completions written as older shells

- less common need, but I don't think there is a way to do something like `exec {myvar}>file`

- I don't think there is an equivalent of `<(command)` to pass the output of a command to another command as a file. Although that could probably be implemented as a plugin pretty easily.

> I don't think there is a way to do something like `exec {myvar}>file`

I might be misunderstanding this, but piping to `save` is how you usually redirect to a file in Nu: https://www.nushell.sh/book/commands/save.html

`exec {myvar}>file` will open a file descriptor that can write to `file`, and then store that file descriptor in the variable `$myvar`, so you can then redirect additional commands to it with `>$myvar` or `>>$myvar`.

From the bash man page:

> Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. In this case, for each redirection operator except >&- and <&-, the shell will allocate a file descriptor greater than or equal to 10 and assign it to varname. If &- or <&- is preceded by {varname}, the value of varname defines the file descriptor to close. If {varname} is supplied, the redirection persists beyond the scope of the command, allowing the shell programmer to manage the file descriptor himself.

Thanks, I was misunderstanding.
I daily drove it for a few months but eventually switched back to zsh. Besides a few features it was missing, I realised that I just don't use shell features much, so it's superior pipelining with proper structured data ended up being a hindrance because I couldn't just copy paste scripts from the web
Thanks, that makes a lot of sense. I use Fish so I'm used to having to occasionally translate snippets from the web by now. (I try and tell myself it's good to understand what the commands I'm copying from random internet guides actually do, but to be honest that does not make it feel less annoying when it happens.)
Giving this a favorite, so I remember to come back to it later. I don't know if I need (or want) yet another shell, but this looks cool enough to at least merit a try.
I appreciate how much time this probably took. I've used it a few times and I'm a huge fan.
So a while ago I had this idea (which probably everybody has had) to make a shell that passes structured data, like lists or tables around. And then, just like how everybody writes complex completion scripts for all sorts of command line tools, build parsing wrappers around legacy tools, so you don’t need to rewrite git and company.

Is that what Nushell is in a nutshell?

Yes, mostly. It has a lot of shell built-ins and a plugin interface so you don't need to manually parse everything, though.

I think it really clicked for me when i read somewhere in an example `ls | sort-by size` and `ls | where size > 100mb`. They are both simple operations that i cannot accomplish from memory using standard POSIX tools, yet one year later i can remember the nushell example very well.

I have been using nushell on Windows for a long time. It has a feel similar to Linux shell and yet it runs natively on Windows. This release is definitely a huge bump and really appreciate how shiny it is.
I really like the idea of Nushell.

  > /Users/tom> ps | grep "k9"
  Unsupported: Row(Dictionary { entries: {"pid": Value { value: Primitive(Int(359)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "name": Value { value: Primitive(String("backupd-helper")), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "status": Value { value: Primitive(String("Unknown(0)")), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "cpu": Value { value: Primitive(Decimal(BigDecimal("0.000000000000000"))), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "mem": Value { value: Primitive(Filesize(0)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }, "virtual": Value { value: Primitive(Filesize(0)), tag: Tag { anchor: None, span: Span { start: 3, end: 5 } } }} })
  error: Received unexpected type from pipeline (row)
    ┌─ shell:2:6
    │
  2 │ ps | grep "k9"
    │      ^^^^ expected a string, got row as input
I understand what happened here, but sometimes I really want to just grep through stuff. It's not clear how to do this and there isn't much in the docs about it. Without this I'm not sure I could actually switch.
Hi, the `find` command is probably easiest: https://www.nushell.sh/book/commands/find.html

ps | find k9

That will search through every column in the `ps` results. If you want to look through just the name column:

ps | where name =~ k9

Is there a command to string-ify the input so that you can use standard Unix coreutils, etc. on it?

This was always my big annoyance with Powershell too, the shell builtins and functions were powerful, but interacting with "dumb" old-style programs that expect and emit streams of text was cumbersome.

Also, is `ps` here a wrapper or shell builtin? Or is Nushell actually parsing the output from the `ps` program?

ps is a shell builtin in Nu (and you can check that with `which ps`).

Going from Nu to raw text is currently a little awkward. `str collect (char nl)` will take a Nu list of strings and convert it to raw text with line breaks. I suspect we'll get a more ergnomic way to do this soon.

Going to Nu from raw text is nicer, the built-in `lines` command splits line-break-delimited text into a list of strings. From there you can use lots of Nu tools to operate on each line.