Wrote up my thoughts on why #nushell matters. And yes, they get a bit spicy 😅

https://www.jntrnr.com/case-for-nushell/

The case for Nushell

Sophia June Turner

@jntrnr #Nushell looks very interesting, thanks for the writeup!

I see that plugins can be made in any language that speaks JSON/MSGPACK¹, that's awesome.

The 'Coming from Bash' page² is also helpful.

Do you use #nushell as your actual shell? Or only for specific tasks?

¹https://www.nushell.sh/book/plugins.html
²https://www.nushell.sh/book/coming_from_bash.html

Plugins | Nushell

A new type of shell.

@nobodyinperson

I've used it as my daily driver shell since the beginning. I also use it as my main scripting language, so all the scripts I write these days for various tasks are all Nushell.

@jntrnr i really appreciate the framing of "look it's really more of a scripting language project"

my main interaction with shells and shell scripting is "this is a temporary hell i get to live in when i want to bootstrap a usable environment with real tools and languages on a random machine"

...which necessarily precludes anything that isn't lowest-common-denominator. heck WSL defaults to /bin/sh being *dash* which is *weaker* than bash

@Gankra @jntrnr I get the "temporary hell" feeling when I'm in any shell other than bash 😅

(Well, or zsh and other similar ones.)

I used to write bash scripts long ago, but a recent foray into YunoHost debugging tells me I've lost the skill. My current scripting go-to is Perl, which makes it super simple to make pipe-friendly scripts. But would be awesome to have one language that's the shell as well as the scripting! 🐫

@Gankra @jntrnr tbh I should also explore zsh more; the main reason I changed is that Manjaro's using it as default and the prompt looked prettier + I now like its autocompletion features. But I never got into full scripting with it 😛

@jntrnr I generally agree with your intention that "we need something better", and in particular that it'd be nice to use structured data, but fact of the matter is, all applications emit just plaintext. Having to write separate plugins to give it form sounds no better than the current state of affairs, since they're third-party...

Not to mention—communication between two programs is still a matter of convention, just a different one. So I'm not sure much is gained there.

@issotm

It's becoming increasingly common for apps (esp. modern cli apps) to optionally output json. This is a workable stand-in for outputting the structure directly, and it's easy for Nushell to take the json and use it.

@issotm
But for nushell you can just write the plugin once and be done with it. Instead of all the userz having to parse it.
@jntrnr
@aiono @jntrnr That's assuming upstream distributes such a plugin, otherwise each user will end up having to write their own anyway.
@issotm
Yeah that's true. That's what I seen in practice for other shell extensions like oh my zsh. IMO it's still significant improvement over the current state of things.
@jntrnr
@jntrnr Looks nice! fyi, I `brew` installed it and ran it in the default Mac OS Terminal.app, and when I type ⌘-K (which I do habitually), the prompt and input cursor show up at the top of the screen (as expected), but when I start typing, jump to the bottom (which I didn't notice for like several minutes, and thought nothing was showing up when I typed! 😂 🤦)

@zellyn

Yeah, that resize/cursor position issue is one we're looking into. Not entirely sure what's causing it but would love to fix it.

@jntrnr the main reason I haven't tried it is an overload of new things and not enough time to try them all.

The one that has really worked is neovim, because I could adopt it incrementally. Can't do that with a new shell.

@j2kun

you could start by writing scripts in it, and then build from there

most of the common shell things will work similarly (cd, ls, mv, rm, etc) but really dig in takes getting used to the nushell way

@jntrnr using it as a scripting language isn't a bad idea...
@jntrnr this is a great blog post about #Nushell. and coming up even better #ScreenReader support. it's slices and dices #DATA and probably even juliennes fries.
and now, how much would you pay?
#A11Y #Accessibility

@jntrnr
Very well put.

I always annoyed by people who advocate things like Unix pipes but contend with existing commands that has most flags for input/output manipulation. If you really want to be consistent with Unix philosophy than one needs a structured shell and command just outputs structured data.

@jntrnr As someone building an `ls` with 45 arguments, you are absolutely right 😄 I know all the original utils quite well now and still feel **much** more comfortable scripting in nu than in bash.

I'm super excited for the collaboration between uutils and nushell. I hope that might help with removing some of that inertia by giving people more flags that they are used to from bash (but only the flags that make sense in nushell of course).

@terts What’s uutils and the collaboration?

@finestructure uutils is a reimplementation of the GNU coreutils (and findutils) that I help maintain. We're collaborating with nushell to bring some of the commands over to nushell as built-in commands with good integration and pretty errors.

uutils homepage: https://uutils.github.io/
PR (very much WIP) to get uutils cp in nushell: https://github.com/nushell/nushell/pull/10097

uutils

@terts Ah, that's great to see. Thanks for the details!

@jntrnr mostly-irrelevant nit: zsh has a for loop shortcut that's even nicer than fish's imo: `for i in $(seq 1 10); echo $i` ; you give bash syntax in the article, which zsh supports, but that's a nice touch.

(I like and use nushell occasionally)

@jntrnr (Also you don't even need `seq`! in both bash and zsh, `{1..10}` does the same thing. With the zsh shortcut synatx, you get `for i in {1..10}; echo $i` which is quite nice)
@jntrnr In a way POSIX is bad and very text focused because UNIX is kinda bad and file focused. People have Stockholm syndrome with shell pipelines so they feel like everything is a file also a great thing until they have to sit down and snprintf() tediously figured out magical paths and parse driver info instead of reading structured data directly...
@jntrnr I'm using it in one work environment with great results ... Sorta juggling 3 shells in practice though, I now switch between bash / fish / nushell at will based on whichever seems fastest to do a given task. An intermediate step I hope

@jntrnr For me, anything above a line or two is automatically in Python or (preferably) Rust, so a new scripting language isn't the biggest priority. On the command-line, I rarely do data processing, so that also doesn't doesn't give me much incentive.

What I'm really intrigued by is the idea of using nushell as an embedded scripting language, as a modern TCL. I imagine that'd be a lot of work though.

@jntrnr
I really like nushell but I can't use it as my main shell as I frequently suspend vim and in nushell that leaves me unable to do anything. I could modify the way I do things to use a multiplexer but, I'm afraid it is too ingrained.
@jntrnr I know it's not exactly the point, but today I learned that you worked on Chapel. Cool
@miguelraz_t @jntrnr
I know, right! Admittedly, I've never used it, but it's always felt like one of the really innovative languages out there for computational science.
@jntrnr I think I will defs try out nushell on Windows, why not!
@jntrnr What I personally would really like to see in a Shell someday, though that would be a radical deviation from the common standard, is some kind of noun-verb structure (where the first argument comes before the command), along with static-ish typing for arguments / return values with help from Libmagic / file extensions to figure out what type of data we're dealing with. The rationale here is that you usually work with objects in or close to your working directory, and there are (usually) far fewer of them than your commands in $PATH, and that makes autocompletion a lot easier. Once the shell knows what file you want to operate on (and can check what type of file it is), it can narrow down your suggestions to only the commands that can actually work with that file. I have a suspicion that this style of working would be a lot faster and more ergonomic, even more so if Copilot-like tools finally come to the terminal.

@jntrnr I'm using #nushell for quite some time (over 2y now), but I got very simple needs, `cd` fire some command, ls, and git.

I happened to write few small scripts to process CSVs, cause it makes it quite easy.

bash/zsh are indeed old (and can be really slow), but changing them on remote machines is a no-go (where all the scripting usually requires posix shell).

I can't see good argument for fish tho, it's got different syntax and when I tried it - no windows support.

@jntrnr P.S. Powershell with it defaulting to utf-16 is just a simple no (at least from dev perspective, although I've seen some nice scripts written by what one could call business people).
@gim I have not seen a more pleasant interactive experience like #fishshell provides (and not just great completion system), at least not without any configuration at all, and the language is a step forward compared to posix shells (more consistent, more clean)

@jntrnr I went in to try it again, and nushell doesn't support the way that I do config, which is a blocker for me:

https://github.com/nushell/nushell/pull/8682
https://github.com/nushell/nushell/issues/893

Why in the world did the team decide to reject a user's choice of where the config should live? The PR gives no reasoning at all.

feat!: use `~/.config/nushell` as the primary config directory by utkarshgupta137 · Pull Request #8682 · nushell/nushell

Description Use ~/.config/nushell as the primary location on all platforms & allow fallback to the existing os-specific locations. Fixes #893. Fixes #8256. Resolves #2918. Resolves #8263. User-Faci...

GitHub

@jntrnr to expand a bit: an important part of shell config for me is that I can bring it between several computers on several operating systems; to do so I keep it in source control and in `~/.config`. (A few programs only support the root `~``, which isn't great but I live with it.)

nushell choosing to use only OS-specific directories means that I can't use my normal config system to move between OSes without adding significant complexity to my config system.

@jntrnr
Makes me want to try nushell again!

Most of my scripting needs these days are around exploring data from Sentry issues, where their web UI isn't good enough. I load a few dozen or thousands of events, throw certain properties into buckets, then see what different kind of root causes I can find. I often miss an option to easily cache the API response, which sometimes takes a minute to load all the data. I wonder how nushell fits in there?

@bassistance

Depends on how you like to do it, but I sometimes just immediately start by creating a new variable to put everything into.

```
let foo = (call to external website)
```

Then at least I don't have to call the website again, I have it in memory. Then, I can write it out to a file or process it or whatever.

Beyond that, we don't offer anything special for caching.

@jntrnr
Makes sense. It's probably easy enough to write a little file system caching abstraction that uses the URL as cache key.

Using nodejs works for this kind of scripting, but I think the interactivity of nushell would fit much better while exploring the data.

@jntrnr "Finally, a command
line shell for the 90s" is irony! It is a joke to emphasize that shells like Bash are too old and #FishShell has modern features.

Indeed, the first release of Fish was 2005.

@mo8it

I call that out the irony in the post. 😅

To your second point - fish *isn't* modern. That's why fish's creator started https://github.com/liljencrantz/crush which is another structured shell. I think that says a lot.

GitHub - liljencrantz/crush: Crush is a command line shell that is also a powerful modern programming language.

Crush is a command line shell that is also a powerful modern programming language. - liljencrantz/crush

GitHub
@jntrnr the problem with structured shells, is that for a seamless experience you'd have to rewrite every single utility to understand that structure, and that structure is specific to a single shell.

@hjvt

In practice, it's not this bad. Nushell comes with utilities to help handle output of external commands. It can also output text that's easy to parse.

Said another way it's no worst than posix for interop (text) but at its best it's much better.

@jntrnr I need to give nushell a second try.
@clementd @jntrnr I really like it for scripting. I have tried using it as my main shell and quite like it, but it makes certain things very difficult, and it can be slow sometimes.

@samir @clementd

interesting - I'd be curious what kinds of things you're finding it's a bit slow to do

@jntrnr @clementd Mostly processing structured data. It’s very good, but I will still reach for jq when iterating on processing a large JSON document, for example. I think it’s the parsing and rendering that takes up most of the time. (I really like that it chunks large output though.)

@samir @clementd

fun fact, we're doing a massive refactor as we speak to make large data values (like large csv's or large json files) work better.

Not sure when it'll fully land. I'd estimate it's ~50% complete.

@jntrnr @clementd Fantastic! Thanks for all the amazing effort.

I would like to contribute to nushell at some point. I think I’m getting closer to the point where I can.

@samir @jntrnr Last time i tried, what I missed was:
- direnv integration
- `!!` and `!$`
- fallback to bash completion in some cases

@clementd @jntrnr That first one is solved, at least: https://www.nushell.sh/cookbook/direnv.html

The other two, I completely agree. Pun entirely intended.

Direnv | Nushell

A new type of shell.

@samir @clementd

we've got `!!` and `!$` support interactively in the shell

@jntrnr that was a good read and I share that vision. Do you have anything written about TUIs?

@phaazon

they're not really a focus for me. I'm mostly focused on the structured data processing side

@jntrnr you know what, I think I'm convinced! 👀

@jntrnr thanks for that writeup, I was aware of nushell before but now I'm motivated to give it a try.

I'm also intrigued by oil shell because it tries to be backwards compatible with bash. So a C++ to bash's C - and likewise that means lots of warts, but a straightforward adoption path for big projects and organizations already using bash extensively.