3 ms·
Today I learned (after disappearing down a rabbit hole after reading the linked article) that it's actually possible to begin to use & benefit from nushell's st
by follower 3y ago
Today I learned (after disappearing down a rabbit hole after reading the linked article) that it's actually possible to begin to use & benefit from nushell's structured data pipe feature without changing one's current shell.
Structured data pipes have always been my primary reason for keeping an eye on nushell's development but after looking at the project's documentation again today it all still seemed "too much initial effort with uncertain outcome".
Because I don't want to switch my shell (not because bash is good but because it's not a priority to justify the expenditure of effort), I just want to have structured data in pipes within bash!
Turns out it's as easy as:
nu --commands 'ls | where size > 1MiB'
(Where `nu` is the nushell binary being called from your existing shell prompt.)
Or, as more complete flow of data example:
echo "[1,2,3]" | nu --stdin --commands 'from json | to json' | cat
Now you can fit nushell within your existing workflow where ever it's useful enough for you--without needing to commit to changing your entire shell.
(And this isn't the only or necessarily the best way to arrange things for the communication with bash--there's "^" & "externals" & "command signatures" & "from ssv" etc too.)
And nushell does have some nifty tools such as `explore` with `:try` to interactively build a processing pipeline.
But this information doesn't seem to be documented anywhere in the "book" or other introductory material. It only seems to be documented in the help message of the `nu` binary--which I almost didn't even get as far downloading today.
But then I found the help text in the source, so decided to try it again: https://github.com/nushell/nushell/blob/fd4ba0443d01e67f6304b7220ef414a33287bdbe/src/command.rs#L248 https://github.com/nushell/nushell/blob/fd4ba0443d01e67f6304...
If the structured data pipes is one of the main appeals for you, maybe try this approach out?
- lelanthran 3y ago> Turns out it's as easy as: They should have lead with that. I ignored nushell only because of the limitations of using a non bash shell with no sequence of commands using ;, && and ||.
- ramblerman 3y agoNice, that's a great way to begin using it and testing the waters.
- follower 3y agoAs a follow-up on this comment, I wrote up[0] some more of my discoveries with regard to using nushell structured data pipes from other shells (e.g. bash). Another variant to allow bash piping but preserving (most of) nushell's data type is with the use of `from/to nuon` commands rather than `from/to json`: nu --stdin --commands 'ls | to nuon' | nu --stdin --commands 'from nuon | where size > 100MiB' I also discovered an existing discussion[1] related to this topic which includes a link[2] to a "helper to call nushell nuon/json/yaml commands from bash/fish/zsh" and a comment[3] that the current nushell dev focus is "on getting the experience inside nushell right and [we] probably won't be able to dedicate design time to get the interface of native Nu commands with an outside POSIX shell right and stable.". [0] https://gitlab.com/RancidBacon/notes_public/-/blob/main/notes/notes--nushell.md#using-nushell-structured-data-pipes-from-other-shells-eg-bash https://gitlab.com/RancidBacon/notes_public/-/blob/main/note... [1] "Expose some commands to external world #6554": https://github.com/nushell/nushell/issues/6554 https://github.com/nushell/nushell/issues/6554 [2] https://github.com/cruel-intentions/devshell-files/blob/master/examples/nushell/nuon.nu https://github.com/cruel-intentions/devshell-files/blob/mast... [3] https://github.com/nushell/nushell/issues/6554#issuecomment-1672012053 https://github.com/nushell/nushell/issues/6554#issuecomment-...
- leadingthenet 3y ago> And nushell does have some nifty tools such as `explore` with `:try` to interactively build a processing pipeline. > But this information doesn't seem to be documented anywhere in the "book" or other introductory material. It only seems to be documented in the help message of the `nu` binary--which I almost didn't even get as far downloading today. https://www.nushell.sh/book/explore.html#try-command https://www.nushell.sh/book/explore.html#try-command
- follower 3y agoYes, `explore` & `:try` are documented[0] but by "this information" I was referring to the `nu` binary's `--commands`, `--stdin` etc. [0] When writing my original comment I had been going to link to page you linked but decided it would just clutter an already long comment no one would read anyway. :)