Live data from Hacker News

Nushell: Introduction to a new kind of shell

dataswamp.org

221–230 of 252 posts

Re: Nushell: Introduction to a new kind of shell

#221

Earlier quoted context omitted.

Bash is not the best we can do! If you want a traditional Unix-like shell that is mostly sensible in the places where Bash is not, check out Zsh. It has a ton of complicated features, but most Bash scripts can be ported easily (if not outright copied and pasted). Zsh has fewer footguns by default than Bash, and it has more "safety" settings that you can enable. There is also the Oil shell, whose creator often posts o…

Since I can't edit my post anymore, here are some additional thoughts: Traditional shell scripting languages are great at exactly three things: typing commands interactively, running other programs, and sourcing other shell scripts. They are also is distinct in that they are "stringly-typed" (i.e. everything is a string), and moreover that syntactically bare symbols are also strings. Typing commands interactively is…

I would also like to add for a better shell:

Please add another standard output stream.

stdout is for output

stderr is for error messages

stdlog for status/tracking, verbose output, event streams. Too often this gets shunted to stderr, and I don't want to logfile hunt. Other examples: download status from curl, verbose output flags in things like ssh and other comm programs that need configuration debugging on the regular, and others.

Nushell seems to also focus on json output for commands. I think this should be a requirement pushed into all unix commands that do output (LS! please please please a json output flag for simple ls which CANNOT BE PARSED RELIABLY).

Re: Nushell: Introduction to a new kind of shell

#222

Earlier quoted context omitted.

I would recommend Oil! http://www.oilshell.org/release/latest/doc/idioms.html It removes the need to quote every variable, and this is fantastic

FWIW this is also the main selling point of Zsh. I should go through this document in detail (thank you for linking it!) but a quick search shows that Zsh is not mentioned even once, and I think a Zsh comparison would be really valuable for people like me. Or is it like Neovim vs. Emacs at that point, where neither one is "better" and it's just a matter of taste and/or whichever one you happened to try first?

Well I actually use zsh (I always mean to switch to oil though), and.. in zsh, you don't need to quote variables? Are you sure?

Oh.. I just tested here. It works!

  $ mkdir -p /q/a\ b/x
  $ a="a b"
  $ ls /q/$a
  x
And in bash:

  $ a="a b"
  $ ls /q/$a
  ls: cannot access '/q/a': No such file or directory
  ls: cannot access 'b': No such file or directory
The weird thing is, my shell is zsh but my shell scrip ts are all either #!/bin/bash or straight #!/bin/sh, so I never took advantage of this

Anyway, I want to link also to

http://www.oilshell.org/release/latest/doc/upgrade-breakage....

http://www.oilshell.org/release/latest/doc/warts.html

http://www.oilshell.org/release/latest/doc/known-differences... <- here it talks about zsh a bit

Re: Nushell: Introduction to a new kind of shell

#223
post #196

Earlier quoted context omitted.

Bash is not the best we can do, but it is definitely the best that most people agree on. I fear there will be no defacto bash replacement for many years.

What do you mean by "agree on"? We never agreed the programming language, which means ... that I can choose whatever I like.

what's the default/defacto scripting language on all unix or unix-like operating systems?

Bash. (except MacOS I guess)

why? because it is the best thing that everyone can agree on as being the stock shell that should always be installed by default.

until we collectively agree on a replacement, bash will remain, along with all of its problems and everyone will write for it because it's the standard shell that's always installed.

many much better shells exist. we can't agree on what should supplant bash, and so it remains. everywhere.

Re: Nushell: Introduction to a new kind of shell

#224

Earlier quoted context omitted.

Why use this over PowerShell for example?

I am a C# programmer at heart, and I use powershell a good bit. I can honestly say I can never use powershell without my cheat sheets or my list of favorite commands (and especially the arguments to use). I looked at this and kinda get it and think I could do some things with it. I don't think it's as powerful and can _definitely_ say it won't be capable of the same automations we use. That said, the text parsing peo…

I use pwsh as my daily driver, and the verbosity actually reduces my need for a cheatsheet.

What I'd love is for Powershell to _stop_ adding .\ to my tab completed files. Just quote it and leave it alone, unless it's an executable.

Once I got used to stuff parsing as objects, it's really hard to go back to everything-as-a-string in bash. I've gotten to writing a few personal scripts/modules.. processing stuff in JSON is just really nice.

Re: Nushell: Introduction to a new kind of shell

#225
post #102
post #67

Earlier quoted context omitted.

Do you use pwsh as your daily driver? I find that its commands are as easily memorable as any other shell. That being said You should enable these: Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete Set-PSReadLineOption -PredictionSource History MenuComplete will give you a menu of arguments that each command takes so you can easily see them when pressing tab for completions and prediction source will try to pr…

Also make sure you're on latest version of PSReadLine (I had some problems with it not updating properly and had to do a manual `Install-Module PSReadLine -Force`) and try Set-PSReadLineOption -PredictionSource HistoryAndPlugin -PredictionViewStyle ListView You can also toggle between the default inline and listview with F2. Also if you install Install-Module CompletionPredictor and add this to your profile: Import-M…

/mind blown/

very nice.

Re: Nushell: Introduction to a new kind of shell

#226

Earlier quoted context omitted.

A shell is pretty much what you described. More accurately it’s a program for interacting with the operating system, and it usually ships with a scripting language, and Utility programs. Hence the conflation. If you’re using Windows Terminal, you’re using a sort of predecessor to Powershell (somebody please correct me on this), if you’re using terminal on Linux, you’re most likely using bash. Enter ps -p $$ at your L…

> If you’re using Windows Terminal, you’re using a sort of predecessor to Powershell (somebody please correct me on this) Not necessarily. Windows Terminal is just a terminal emulator; you can run any shell in it: cmd.exe, PowerShell, Nushell, bash, fish...

And what a great Terminal emulator it is.

Re: Nushell: Introduction to a new kind of shell

#227

Earlier quoted context omitted.

> If you’re using Windows Terminal, you’re using a sort of predecessor to Powershell (somebody please correct me on this) Not necessarily. Windows Terminal is just a terminal emulator; you can run any shell in it: cmd.exe, PowerShell, Nushell, bash, fish...

And what a great Terminal emulator it is.

Agreed; it’s a massive step forward for Windows and the team behind it is great.

Re: Nushell: Introduction to a new kind of shell

#229

Earlier quoted context omitted.

FWIW this is also the main selling point of Zsh. I should go through this document in detail (thank you for linking it!) but a quick search shows that Zsh is not mentioned even once, and I think a Zsh comparison would be really valuable for people like me. Or is it like Neovim vs. Emacs at that point, where neither one is "better" and it's just a matter of taste and/or whichever one you happened to try first?

Well I actually use zsh (I always mean to switch to oil though), and.. in zsh, you don't need to quote variables? Are you sure? Oh.. I just tested here. It works! $ mkdir -p /q/a\ b/x $ a="a b" $ ls /q/$a x And in bash: $ a="a b" $ ls /q/$a ls: cannot access '/q/a': No such file or directory ls: cannot access 'b': No such file or directory The weird thing is, my shell is zsh but my shell scrip ts are all either #!/bi…

The only thing to keep in mind about Zsh parameter expansion is that unquoted empty values will be dropped entirely, while quoted empty values will be treated like the empty string '':

    show_nargs() { print $# }

    q=
    show_nargs $q    # 0
    show_nargs "$q"  # 1
So it doesn't completely solve the need for defensive quoting, but at least it mitigates the need for the most part.

Re: Nushell: Introduction to a new kind of shell

#230

Earlier quoted context omitted.

What are the features that are done differently, or in other words, why would I choose Nushell over PowerShell?

I'm one of the Nushell developers, and one of the main reasons I joined the project was that I couldn't find a cross-platform shell I was happy with. PowerShell has a _lot_ of baggage. I don't like a lot of their design decisions (ex: the super verbose naming, the continue-on-error default that makes scripting a pain), and it's unlikely that those decisions will ever be revisited. I tried pretty seriously to use Powe…

> the super verbose naming

Isn’t long names but short aliases the pragmatic way of solving the naming problem? “ls” or “dir” is perfect when typing interactive but in a long program I don’t mind typing something longer out.

Startup perf is definitely an issue but otoh that doesn’t feel like a design decision that couldn’t be fixed.

Post reply on HN