For those of you unaware: https://nushell.sh/

This is by far the most unique shell out there, since it doesn’t use raw text as output/input to command line calls, but instead an actual data structure. It’s like if every CLI call returned a database table, in a way.

  • @Cyberflunk@lemmy.world
    link
    fedilink
    61 day ago

    PowerShell is very similar to nushell, structured data output. Nushell hasn’t sold me over fish, as completions, prompts, all that is barely fledgling

  • @brian@programming.dev
    link
    fedilink
    172 days ago

    I love alternative shells. my shell has been set to fish and zsh for about a year each, xonsh for a few years, and now nushell for a couple years, and I think that’s probably my ranking as well.

    fish and zsh are both nicer than bash, but they don’t give you as much as xonsh and nu do. you get nice completion and configuration and such, but it’s still a shell when it comes to the programming tasks.

    I don’t want just a shell, I want a programming language with a good repl that makes it easy to deal with commands. xonsh and nushell both do that.

    my major problem with xonsh was that there was python syntax, and there was shell syntax. it didn’t feel great to interleave sh cmds and py fns. everything had to be parsed and then everything had to be formatted to go back into sh cmds. the standard library of sh cmds doesn’t really exist either. you either use the py version of libraries for paths/processes/whatever, or you call and parse the os version. the former seems like the intended one. I found myself having to find a pip package for whatever task.

    nu solves all my problems with xonsh without sacrificing much. there isn’t really a split between nu commands and shell ones syntactically. parsing is easy, most cli things output data as lines, ascii tables, or have a json flag, and nu has nice ways to deal with all of those. nu commands generally work given a single element or a list or a full table if they make sense to. running a command on each element in a list and dealing with the output is easy as opposed to having to break your pipeline and write a for loop. they also have plenty of builtins and plugins so the things I generally want to parse are already done. ls returns a table, ps returns a table, I can pass lists into rm, etc. there’s community plugins for git so I don’t have to remember their syntax for searching for commits, I just query in nu. aws cli has a json flag so I can explore logs and such as nu data. and if I just want.

    now downsides to nu. it’s not bash so you can’t just source whatever file that a command probably gives you, and there’s no source-bash like xonsh has, so you’re stuck translating it to nu. if it just sets env vars it’s not awful since you can just shell out to bash, but doesn’t work for more complicated. for things like python you have to make sure you use the correct tool to make your venv since builtin one doesn’t give you a nu file to load. not sure about support in other tools.

    overall it’s great and not really that much learning, especially if you just use it like a shell to begin with. it’s not much commitment to try a new shell since you can still call scripts written in your previous one. I’d say try it and see how it goes

  • @Kissaki@programming.dev
    link
    fedilink
    English
    8
    edit-2
    2 days ago

    More specifically answering your question of is it worth learning:

    It’s very interesting because it’s very different to other shells.

  • @Kissaki@programming.dev
    link
    fedilink
    English
    6
    edit-2
    2 days ago

    Yes, absolutely.

    I’ve been using it for a while. I’m not super/very command-line centered, but I use it as my default shell on Windows. I did not set it up as a default shell on [my] Linux servers.

    There was a bit of a time investment in making the switch, but I enjoy it a lot, and have used a few data querying and transformation functionalities that would have been much harder in other shells, requiring additional apps; I would have probably created custom C# CLI apps for them. Nushell allowed me to do those in the shell, directly, with native operations.

    I’ve also set up a few very useful aliases and commands; Like dl for yt-dlp, and dl opus for downloading highest quality opus audio. Or ff for a few ffmpeg conversions.

    I’ve also contributed a bit upstream. Maybe I’ll get more into Rust and be able to contribute more, and to the core.

    I have my setup/configuration and scripts in a public nushell-config repo.


    Examples, of how I used it productively:

    Download my paged Steam reviews because Steam doesn’t provide GDPR compliant exports, transforming the awful shitty HTML with query web into structured data, and transforming it into Markdown files for my website.

    At work; For a list of device IDs, create JSON command files, transform them into BSON via CLI call, en-mass. (We have multiple hundreds such devices. Configuration and firmware updates require mass-updates via individually addressed command files.)

    Parse and analyze DMARC reports for reported issues, and to identify report format differences from different reporters.

    I’m sure I did more things, but that’s what came to mind right now.


    Because of how much I love Nushell, I’ve created a community a little while ago, !nushell@programming.dev, if you’re interested.

  • @thingsiplay@beehaw.org
    link
    fedilink
    72 days ago

    The problem with this is, the standard tools do not output in the format this requires. Windows PowerShell has a similar idea behind it, but at least the system is designed for this in mind. That’s why I think its not really worth learning and using Nushell as the default shell. Maybe I’m wrong. Would love to hear why.

    • @brian@programming.dev
      link
      fedilink
      72 days ago

      worst case you’re parsing command output like you would in bash, so you’re not really worse off. I’ve got a handful of aliases that wrap commands I run often so I only dealt with parsing in the beginning. there are enough builtins that output structured data, or applications that have a json flag that it’s still useful.

      speaking of powershell, it’s easy enough in nushell to write an alias that shells out to pwsh and calls ConvertTo-Json then from json on the nu side. that gives you plenty of extra commands that are structured, at least on windows

      • @mormund@feddit.org
        link
        fedilink
        42 days ago

        Why not just use Powershell then? It’s been available for Linux for a long time. I use it for scripting quite often

        • @brian@programming.dev
          link
          fedilink
          42 days ago

          bc nu does everything pwsh does, but without the odd and verbose syntax. their exceptions and error codes are two different systems and don’t make sense by default. instead of making shell cmds easy to parse I find myself having to use dotnet versions of things, which would be fine if the syntax for that wasn’t so terrible. nu still feels like a unix shell for the most part.

          pwsh has its place, especially since it’s default. I’ve written plenty of pwsh scripts at work for ci and the like. I can get over the verbose naming in a text editor. using it from a repl isn’t my favorite experience

        • @Kissaki@programming.dev
          link
          fedilink
          English
          22 days ago

          I always had an aversion to PowerShell syntax.

          They’re certainly both object shells. If you’re already familiar with PowerShell, there’s probably no reason or need to switch. I’m not familiar with PowerShell enough to identify where else they differ.

    • @Kissaki@programming.dev
      link
      fedilink
      English
      2
      edit-2
      2 days ago

      What do you mean by standard tools?

      I feel like many if not most of what I would consider those are CLI tools other shells require because they themselves do not provide the functionality, whereas Nushell does.

      What do you mean by PowerShell is designed with that in mind while Nushell isn’t?

      • @thingsiplay@beehaw.org
        link
        fedilink
        11 day ago

        The system tools have the output of what PowerShell offers, or doesn’t it? I actually don’t use Windows. In Linux the standard tools are stuff like grep, i don’t know everything in the system is designed with stdin and stdout as lines and similar. Nushell requires the programs to understand Nushell, so its kinda like its enclosed system and not really a Shell in my opinion. It does not integrate (at least in Linux) into the other tools as well. That’s why they provide a few extra tools that only work in Nushell.

        Not saying this is a bad approach, its just not what I would do.

        • @Kissaki@programming.dev
          link
          fedilink
          English
          2
          edit-2
          16 hours ago

          Nushell requires the programs to understand Nushell

          My point was that with Nushell you don’t need various command line tools like you do on bash or whatever. The question of whether those integrate well with Nushell doesn’t even come up/is not central - although it does work with text just fine.

          Nushell integrates very well into various data formats. It can handle text pipelines, but the advantage is in using structured data. You skip the entire text-pipelinie and work on structured data throughout, and don’t need grep or awk or find or du or df or whatever cli tools you would use in a simpler/classic Linux shell.

          • @thingsiplay@beehaw.org
            link
            fedilink
            216 hours ago

            And my point is, this is not a “real shell”, in the sense of “default interactive shell”. It is an encapsulated system that works on its own. Basically like a programming language would be (speaking of programming language, there is also one for Python Xonsh). I don’t have a problem with this approach though, so don’t get me wrong, need to stress this enough. There are many implications here. If one likes this approach of replacing the entire Linux tools stack, its up to them.

            However… just like with any other tool, I think Nushell is an excellent “enhancement” or “additional” tool to what I already use. Especially working with structured data can be very useful. Instead parsing the data myself or using other parser tools like jq or Python, Nushell could do this with all the features it provides. Even though I am not for replacing my own shell with this, I need to look closer to have it as an additional tool installed. From that angle, I see Nushell more like a programming language like AWK (yeah its a full language inside, I think Turing complete) or Python. But I’m not sure I really want to, because I like to share my solutions.

  • hallettj
    link
    fedilink
    English
    32 days ago

    I’ve been using nushell as my shell for a long while. Completions are not as polished as zsh - both the published completions for each program, and the UX for accepting completions. But you get some nice things in exchange.

    I LOVE using nushell for scripting! CLI option parsing and autocompletions are nicely built into the function syntax. You don’t have to use the shell for this: you can write standalone scripts, and I do that sometimes. But if you don’t use it as your shell you don’t get the automatic completions.

    Circling back to my first point, writing your own completions is very easy if you don’t like the options that are out there. You write a function with the same name as the program you want completions for, use the built-in completions feature, and it’s done.

  • fxomt
    link
    fedilink
    52 days ago

    Used to use it, but you can’t run tasks in parallel :/

    eventually switched back to fish, not enough advantages for me to use (i use nu on windows though!)

  • @TheV2@programming.dev
    link
    fedilink
    22 days ago

    I use it as the default shell only in my terminal (with fish completion). You still have to deal with breaking changes and inconsistency. On top of that, you need to wrap a lot of your commonly used commands and tools to take full advantage of it. But personally I consider it worth learning and using. Not only do I hate working with raw text, I also love the visual and interactive data representation. And working with existing tools is honestly not a huge problem. It’s just what you’d usually do regularly. Obviously POSIX-compliant shells in combination with many tools like jq, too are already capable of nushell’s power. But I just like to have it included in the shell language, so I can work with the data more casual.

    I couldn’t tell you why you’d use it instead of Powershell. I just never tried Powershell on Linux.

  • TehPers
    link
    fedilink
    English
    2
    edit-2
    2 days ago

    If you’re fine with breaking changes now and then, then yes absolutely. I use it everywhere, and it’s been a huge boost in productivity for me.

  • Aatube
    link
    fedilink
    11 day ago

    I used it as my default shell while on Windows. I think it’s still gonna be worth it on Linux, but I’m too lazy to care.