Live data from Hacker News

Nushell.sh ls | where size > 10mb | sort-by modified

nushell.sh

91–100 of 215 posts

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#91
post #48
post #36

Earlier quoted context omitted.

It is much much better to have things be actual commands (which have a uniform syntax, and are `--help`able) rather than obscure sigils like $(#!@$). Fish is amazing!

Many of these next-gen shells like Nushell are clearly (and sometimes explicitly) inspired equally by Fish and by PowerShell, and it shows. It's a brilliant combination!

I think the problem with this approach is that it breaks down at some point, and then your only option is to rewrite the entire thing in a real scripting language.

I.e., there is no graceful scaling path.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#92

Earlier quoted context omitted.

Blocks always use braces. Expressions use parentheses for grouping sub-expressions. It's the same as many C-like languages. I can't imagine any situation where you would be confused which one you need to use.

> I can't imagine any situation where you would be confused which one you need to use. Why is that test returning a boolean on the GP a block?

Because it's an arbitrary piece of code that needs to be re-evaluated for every input item, like an inline function / lambda in other languages, not an expression that is evaluated once when the commandline is instantiated.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#93

Earlier quoted context omitted.

The fact PowerShell has this masochistic tendency to have commands that start with capital case already makes it outside of the realm of consideration for me. It's absolute nonsense. Also I have to say your example is extremely confusing and would probably take quite a bit of time to write IRL. For reference, the equivalent in sh would be: find . -maxdepth 1 -type f -size +10M -exec ls -lt {} + Or a very terse exampl…

ls is an alias for Get-ChildItem in Powershell as well, btw

Only on Windows. On Linux it's the original `ls`. Same for `cat` and many other commands. That's why using `gci` / `gc` is safer if you want your script to work everywhere.

https://learn.microsoft.com/en-us/powershell/scripting/whats...

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#94

I like the idea of piping structured data between processes instead of streams of bytes, but that's what PowerShell is for. I don't think I've ever met another dev who likes PowerShell

I'd actually like the ability to do either raw bytes (traditional) or structured bytes (the NuShell/PowerShell idea) in an "opt-in" scenario. This would also allow a smoother transition/lack of needing to fully commit right off the bat. I've considered writing wrappers for standard utilities in Bash/Zsh that accept and output structured data in JSON (or maybe a denser serialization format that can easily convert to JSON?) instead of a raw byte stream that you could then just use regular old pipes with (a lot of `jq` would likely get called in between...) The "structured" versions of the utilities would have some namespacing convention such as a "struct_" prefix (or perhaps optionally, or aliased, for brevity, "s_") or (another naming idea I just had... oooh, I like this one) they would be boxed in brackets, so "[ls]" or "]ls[" would call "structured ls" (note that brackets without spaces around them are valid name characters)

To handle the transition to/from structured data, an idea I had was to omit one of the brackets in these names, so for example "ls[" would emit structured data but accept (well, assuming "ls" was a command that took stdin) an unstructured bytestream, and something like "]cat" would take in structured data on stdin but emit raw data... "cat[" would take raw data and... interpret it as JSON? or something? and output that as structured data? I don't know, it has to be fleshed out, but this could work maybe!

To get the JSON data back to a visual format like a table, we'd probably have to explicitly do what NuShell implicitly calls when you don't provide it (I forgot the name of it).

anyway, I haven't even begun a POC of this idea, but it was one I had. Anyone else like this idea?

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#95
post #91
post #48

Earlier quoted context omitted.

Many of these next-gen shells like Nushell are clearly (and sometimes explicitly) inspired equally by Fish and by PowerShell, and it shows. It's a brilliant combination!

I think the problem with this approach is that it breaks down at some point, and then your only option is to rewrite the entire thing in a real scripting language. I.e., there is no graceful scaling path.

I suppose I'm more optimistic. From my point of view, structures pipelines and some of the goodies that come with it (like better error handling), can make a shell language into a perfectly capable scripting language. I think the big weakness for these new shells is in the small sizes of their library ecosystems. But PowerShell shows what a language of this kind can do with a sizeable ecosystem and some OS integration.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#96

So, '>' isn't for redirection anymore. How does one do that? open foo.txt | append "world"| save --raw foo.txt Oh.

Historically we would discourage shell users from cat somefile.txt | whatever and instead tell them to use either whatever or, if the command accepts input file names as arguments then use those like whatever somefile.txt or whatever -i somefile.txt etc But perhaps in fish, “useless use of cat” is not so useless and would be recommended? (I mean aside from the fact that they seem to recommend their “open” command, an…

The use of cat is not useless. Having a "read this file" command be the source of the pipeline makes a lot of sense. It makes it seamless to replace the cat with a pv if you want progress, zcat if you're reading a gzipped file, curl if you want to use a URL, etc.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#97
post #70

I find this project interesting But doesn't it look like too monolithic? That will have problems with maintenance and scaling? And features that overlap with many already existing cli tools?

I think Nu generally plays nicely with other CLI tools and data sources. For example if you've got an external executable that emits JSON, all it takes is `from json` to convert that output to a Nushell table.

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#98
post #91
post #48

Earlier quoted context omitted.

Many of these next-gen shells like Nushell are clearly (and sometimes explicitly) inspired equally by Fish and by PowerShell, and it shows. It's a brilliant combination!

I think the problem with this approach is that it breaks down at some point, and then your only option is to rewrite the entire thing in a real scripting language. I.e., there is no graceful scaling path.

Isn’t this the problem with older shells as well? Eg you have to use e.g. awk or sed to deal with more complicated text processing. My understanding that the biggest difference between powershell (and nushell) and the older bash-like shells is that they deal with structured, object-like data rather than text. How would things be any different when “things break down” vs an older shell?

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#99
Few more decades of shell development and the people involved will maybe discover GUI with hotkeys. /s

Seriously though, for me their front page fails to give a convicing example how it's better than existing shells for a typical shell workflows.

Even the last one, which supposed to demonstrate better error messages, shows a cryptic error "change a or b to be the right types and try again". Perhaps type checking can help to say which argument is wrong and how to fix it? Now it's literally "one of your arguments is wrong, check man and try again".

Re: Nushell.sh ls | where size > 10mb | sort-by modified

#100

Earlier quoted context omitted.

Historically we would discourage shell users from cat somefile.txt | whatever and instead tell them to use either whatever or, if the command accepts input file names as arguments then use those like whatever somefile.txt or whatever -i somefile.txt etc But perhaps in fish, “useless use of cat” is not so useless and would be recommended? (I mean aside from the fact that they seem to recommend their “open” command, an…

For some reason I never liked to do it the "right way". First of all it doesn't seem to actually matter. But most of all the cat way just aligns with my mental model more. Data flows left to right, if you catch my drift. It also makes it easier to add arguments to the end if re-running it.

I share the same opinion, I was made fun of with the "useless use of cat award" but find it so convienent to cat | grep then cat | grep | awk | wc then whatever with data flowing left to right and modifying the command sequence as I explore the file content.
Post reply on HN