I just ported a bunch of scripts to nushell. I hit some bugs, a couple of which are a bit sharp, but wow, the list of quirks I have to remember for nutshell are so much fewer than for bash. Constantly impressed at the errors it catches at parse time, kinda crazy sometimes. Oh my god I could cry, strings are sane to work with. I may never write a bash script again (it's okay, I use Nix so I get nushell everywhere I'm…
Nushell: Introduction to a new kind of shell
131–140 of 252 posts
Re: Nushell: Introduction to a new kind of shell
#132Do we need a new shell or a few utilities that help produce structured output? For example, `ls | gen_structure | limit 50 | head 5`
And once you've done that, you have this new batch of commands that are structure-oriented, so you are using bash (for example) as a boot loader for your new shell. Why not just use the new shell?
I have a project in this space: https://marceltheshell.org. It is based on Python, so Python values (strings, numbers, tuples, lists, etc.) are piped between commands. No sublanguages (as in awk); instead you write Python functions.
Marcel has an ls command, but instead of producing a list of strings, it generates a stream of File objects which can be piped downstream to other commands that operate on Files.
Example: sum of file sizes under directory foobar:
ls -f foobar | (f: f.size) | red +
-f means files only. In parens is a Python function (you can omit "lambda") that maps a file to its size. red + means reduce using addition, i.e., add up all the file sizes.Or to compute size by file extension:
ls -f foobar | (f: (f.suffix, f.size)) | red . +
f.suffix is the extension. "red . +" means to group by the first field of the tuple (the extension) and add up the sizes within each group.Re: Nushell: Introduction to a new kind of shell
#133I still believes that [xonsh]( https://xon.sh/ ) is the best of its kind because I do not want to remember yet another language syntax
Re: Nushell: Introduction to a new kind of shell
#134How did I not know about this? I will never parse text in Bash again.
Bash (sh) is glue. awk can parse text. As can SNOBOL4 if you REALLY want to go crazy. Or sed. Math is done by expr, dc and bc.
Re: Nushell: Introduction to a new kind of shell
#135I just ported a bunch of scripts to nushell. I hit some bugs, a couple of which are a bit sharp, but wow, the list of quirks I have to remember for nutshell are so much fewer than for bash. Constantly impressed at the errors it catches at parse time, kinda crazy sometimes. Oh my god I could cry, strings are sane to work with. I may never write a bash script again (it's okay, I use Nix so I get nushell everywhere I'm…
bash + lua, and life is good again.
Re: Nushell: Introduction to a new kind of shell
#136Earlier quoted context omitted.
It has Push-Location and Pop-Location, which are aliased to pushd and popd. IDK about dirs -v.
`dirs -v` would be `Get-Location -Stack`. Also in newish versions PowerShell `Set-Location` (aliased to `cd`) supports -/+ to move backwards/forwards in it's own history, so usually you don't even need to bother with `pushd`/`popd` unless you need a named stack.
Re: Nushell: Introduction to a new kind of shell
#137Should have been called nutshell
It is cumbersome to always add a postfix: rust (lang), go (lang), etc...
Re: Nushell: Introduction to a new kind of shell
#138Earlier quoted context omitted.
Error messages are great, autocomplete works out of the box, and commands ArentCamelCaseMonstrocitiesOnlyMicrosoft --CouldLove.
> ArentCamelCaseMonstrocitiesOnlyMicrosoft --CouldLove Personally, CamelCase makes more sense than everythinglowercasesmushedinto -onetwothreefourparametersSometimesCapitalised and --sometimesdoubledashed and -Isometimesspacedoesn'tmatter -and --sometimes - "dashlivesalone" --AND -o -- "twodasheslivealone".
Re: Nushell: Introduction to a new kind of shell
#139Re: Nushell: Introduction to a new kind of shell
#140Do we need a new shell or a few utilities that help produce structured output? For example, `ls | gen_structure | limit 50 | head 5`