- cross-posted to:
- linux@programming.dev
- cross-posted to:
- linux@programming.dev
I’ve been trying nushell and words fail me. It’s like it was made for actual humans to use! 🤯 🤯 🤯
It even repeats the column headers at the end of the table if the output takes more than your screen…
Trying to think of how to do the same thing with awk
/grep
/sort
/whatever
is giving me a headache. Actually just thinking about awk
is giving me a headache. I think I might be allergic.
I’m really curious, what’s your favorite shell? Have you tried other shells than your distro’s default one? Are you an awk wizard or do you run away very fast whenever it’s mentioned?
Until you discover nushell’s (lack of) quoting rules
Can you elaborate?
Last I checked, there was no rigorous system for how quoting worked, such as how to escape a quote inside a string.
Nushell looks cool but I prefer to stick with the POSIXes so that I know my scripts will always work and syntax always does what I expect it to. I use zsh as a daily driver, and put up with various bashes, ashes, dashes, that come pre-installed with systems I won’t be using loads (e.g. temporary vms).
I don’t really mind having a non-POSIX shell since it doesn’t prevent bash scripts from working, but I get that if you want portability bash is still best since it’ll work mostly anywhere.
If I can shebang nutshell (assuming all the builtins from bash or even sh work) and pass a flag to remove all the fancy UI-for-humans formatting so that piped commands int eh scripts work, then I think this is incredible.
Yeah having this installed along side other more “standard” shells is fine I guess, but it looks like maybe it has some neat functionality that is more difficult in other shells? I guess I’d need to read up on it more but having a non-interactive mode for machines to read more easily would be a huge plus for it overall. I suppose that depends on what it offers/what it’s trying to accomplish.
I love NuShell but it is annoying when using LLMs to generate troubleshooting code.
I prefer getting comfortable with bash, because it’s everywhere and I need it for work anyway (no fancy shells in remote VMs). But you can customize bash a lot to give more colored feedback or even customize the shortcuts with readline. Another one is pwsh (powershell) because it’s by default in Windows machines that (sadly) I sometimes have to use as VMs too. But you can also install it in linux since it’s now open source.
But if I wanted to experiment personally I’d go for xonsh, it’s a python-based one. So you have all the tools and power of python with terminal convenience.
Yeah if you need to work on machines with bash it makes sense to stick with it. Sorry you have to work on Windows… how is powershell compared to bash?
I don’t know python but xonsh seems really cool, especially since like nushell it works on both linux and windows so you don’t have to bother about OS specific syntax
powershell, in concept, is pretty powerful since it’s integrated with C# and allows dealing with complex data structures as objects too, similar to nushell (though it does not “pretty-print” everything the way nushell does, at least by default).
But in practice, since I don’t use it as much I never really get used to it and I’m constantly checking how to do things… I’m too used to posix tools and I often end up bringing over a portable subset of msys2, cygwin or similar whenever possible, just so I can use grep, sed, sort, uniq, curl, etc in Windows ^^U …however, for scripts where you have to deal with structured data it’s superior since it has builtin methods for that.
Looks like it’s taken a page from PowerShell in passing structured data rather than just text.
Oh I didn’t know powershell did that too! It sure beats endless parsing errors
That was the foundational concept in powershell; everything is an object. They then went a ruined it with insane syntax and a somewhat logical, but entirely in practice verb-noun command structure.
Nushell is powershell for humans. And helps that it runs across all systems. It’s one of the first things I install.
somewhat logical, but entirely in practice verb-noun command structure.
That’s supposed to be “impractical”, not “in practice”, for others reading along.
For example, the “proper” command to list a directory is:
Get-ChildItem
The “proper” command to fetch a webpage is:Invoke-WebRequest https://example.com/
In these particular cases, they do have aliases defined, so you can use
ls
,dir
andcurl
instead, but …yeah, that’s still generally what the command names are like.It’s partially more verbose than C#, which is one of the most verbose programming languages out there. I genuinely feel like this kind of defeats the point of having a scripting language in the first place, when it isn’t succinct.
Like, you’re hardly going to use it interactively, because it is so verbose, so you won’t know the commands very well. Which means, if you go to write a script with Powershell, you’ll need to look up how to do everything just as much as with a full-fledged programming language. And I do typically prefer the better tooling of a full-fledged programming language…
I’ve had nushell as my daily driver for a couple years now and I love it. “Made for actual humans to use” is exactly the description I’d give.
(…) 'cause it was quarter part eleven
on a Saturday in 1999
🎶🎶
To answer your questions, I work on the Bash, because it’s what’s largely used at work and I don’t have the nerve to constantly make the switch in my head. I have tried nushell for a few minutes a few months ago, and I think it might actually be great as a human interface, but maybe not so much for scripting, idk.
The usual problems with parsing
ls
don’t happen here because Nu’sls
builtin returns properly typed data. You can work with it in pretty much the same way you would work with it in Python, except that Nu has a composition operator that doesn’t suck ass (|
), so you don’t have to write as much imperative boilerplate.I have a number of reservations regarding Nu (the stability of the scripting language, unintuitive syntax rules, a disappointing standard library) but this particular argument just doesn’t apply.
The usual problems with parsing ls don’t happen here because Nu’s ls builtin returns properly typed data.
Isn’t that the point that the previous commenter was making by linking that answer? I read their comment as “here is why you should use Nu shell instead of parsing
ls
output.”
I feel my sanity slowly slipping away while reading…
Yeah, why are linebreaks & co. in names even allowed on file system level? There’s not even something like a restricted mode mount option for most fs.
because why not? it’s just characters and any UTF8 string is allowed as a filename so long as it doesn’t contain a null byte. people’s usecases are different, and you really shouldn’t be parsing
ls
output in the first placeThere’s an argument to be made that system software like filesystems and kernels shouldn’t get too smart about validating or transforming strings, because once you start caring about a strings meaning, you can no longer treat it as just a byte sequence and instead need to worry about all the complexities of Unicode code points. “Is this character printable” seems like a simple question but it really isn’t.
Now if I were to develop a filesystem from scratch, would I go for the 80% solution of just banning the ASCII newline specifically? Honestly yes, I don’t see a downside. But regardless of how much effort is put into it, there will always be edge cases – either filenames that break stuff, or filenames that aren’t allowed even though they should be.
Oh right, filesystem is initialized before charset & stuff. My bad.