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?

  • priapus@piefed.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    18 days ago

    I love Nushell, it’s so much more pleasant for writing scripts IMO. I know some people say they’d just use Python if they need more than what a POSIX shell offers, but I think Nushell is a perfect option in between.

    With a Nushell scripts you get types, structured data, and useful commands for working with them, while still being able to easily execute and pipe external commands. I’ve only ever had two very minor gripes with Nushell, the inability to detach a process, and the lack of a -l flag for cp. Now that uutils supports the -l flag, Nushell support is a WIP, and I realized systemd-run is a better option than just detaching processes when SSHd into a server.

    I know another criticism is that it doesn’t work well with external cli tools, but I’ve honestly never had an issue with any. A ton of CLI tools support JSON output, which can be piped into from json to make working with it in Nushell very easy. Simpler tools often just output a basic table, which can be piped into detect columns to automatically turn it into a Nushell table. Sometimes strange formatting will make this a little weird, but fixing that formatting with some string manipulation (which Nushell also makes very easy) is usually still easier than trying to parse it in Bash.

  • communism@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    18 days ago

    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).

    • nimpnin@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      18 days ago

      Always confuses me when people say this. You can use multiple different shells / scripting languages, just as you can use multiple programming languages.

      • communism@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        18 days ago

        I know that. I just don’t have a use case for alternative shells. Zsh works fine for me and I know how it works. I don’t have problems that need fixing, so I don’t need to take the time to learn a new, incompatible shell.

  • apt_install_coffee@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    17 days ago

    I used nushell for a good 6 months, it was nice having structured data, but the syntax difference to bash which I use for my day job was just too jarring to stick with.

    Fish was (for me) the right balance of nice syntactic sugar and being able to reasonably expect a bash idiom will work.

  • DasFaultier@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    18 days ago

    (…) '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.

    • Ŝan@piefed.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      18 days ago

      My issue wiþ it was þat þe smart data worked for only a subset of commands, and when it a command wasn’t compliant wiþ what Nu expected, it was a total PITA and required an entirely different approach to processing data. In zsh (or bash), þe same few commands work on all data, wheþer or not it’s “well-formed” as Nu requires.

      Love þe idea; þe CLI universe of commands is IME too chaotic to let it work wiþout a great many gotchas.

      • otp@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        18 days ago

        Love þe idea

        Wouldn’t that be a different character because it’s a voices th? Usually that character represents a voiceless th.

        • Ŝan@piefed.zip
          link
          fedilink
          English
          arrow-up
          0
          ·
          18 days ago

          In Icelandic, yes. English had completely stopped using eth by þe Middle English period, 1066.

          • Ferk@lemmy.ml
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            18 days ago

            Didn’t they also stop using the þ in Modern English?

            Why use þ (Þ, thorn) but not ð (Ð, eth)? …and æ (Æ, ash) …might as well go all the way if you want to type like that.

  • bastion@feddit.nl
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    18 days ago

    I like nushell, but I love xonsh. Xonsh is the bastard love child of Python and Bash.

    it can be thought of as:

    • try this statement in Python
    • if there’s an exception, try it in bash.

    Now, that’s not a very accurate description, because the reality is more nuanced, but it allows for things like:

    for file in !(find | grep -i '[.]mp3^'):
        file = Path(file.strip())
        if file != Path('.') and file != file.with_suffix('.mp3'):
        mv @(file) @(file.with_suffix('.mp3'))
    

    Now, there are things in there I wouldn’t bother with normally - like, rather than using mv, I’d just use file.rename(), but the snippet shows a couple of the tools for interaction between xonsh and sh.

    • !(foo) - if writing python, execute foo, and return lines
    • @(foo) - if writing sh, substitute with the value of the foo variable.

    But, either a line is treated in a pyhony way, or in a shelly way - and if a line is shelly, you can reference Python variables or expressions via @(), and if it’s Pythony, you can execute shell code with !() or $(), returning the lines or the exact value, respectively.

    Granted, I love python and like shell well enough, and chimeras are my jam, so go figure.

      • bastion@feddit.nl
        link
        fedilink
        arrow-up
        0
        ·
        edit-2
        18 days ago

        It’s a superset of python, so valid python should run fine. Imports into your shell are doable, too – for example, I import path.Path in my xonshrc, so it’s always available when I hit the shell. I don’t often have to use Path, because regular shell commands are often more straightforward. But when I do, it’s nice to have it already loaded. Granted, that could get kooky, depending on what you import and execute.

        You can associate/shebang Xonsh with .xsh files, or run “xonsh foo.xsh” - and that works like “bash foo.sh” would, except using xonsh syntax, of course.

        It’s not Bash compatible - copypasta of scripts may not work out. But it’s a good shell with some typical shell semantics.

        there are some great plugins, too - like autovox, which allows you to create python venvs associated with specific subfolders. so, cd myproject does the equivalent of cd myproject; . path/to/venv/bin/activate.

        overall, there definitely is some jank, but it’s a great tool and I love it.

        • MonkCanatella@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          17 days ago

          Hm. That sounds delightful. I do think once your script hits a not one liner level of complexity, python is a logical next step.

          Does it provide any useful stuff to Python itself? Would I like, derive any benefit to writing a script in xonsh over pure python?

          • bastion@feddit.nl
            link
            fedilink
            arrow-up
            0
            ·
            edit-2
            15 days ago

            Succinctness, mainly. but honestly, that succinctness call can also be mostly acquired using sh.py, which is what I normally use if I’m using python as a sort of shell scripting - mostly because sh.py is a very minimal requirement, whereas Xonsh has quite a few dependencies.

            addendum: I’d say, if you’re already using Xonsh, and aren’t really looking to share your script with anyone other than Xonsh users or your own systems, you’d probably like to use .xsh scripts. But if you’re looking to share your script, use sh.py.

  • esa@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    ·
    18 days ago

    I’ve been using fish (with starship for prompt) for like a year I think, after having had a self-built zsh setup for … I don’t know how long.

    I’m capable of using awk but in a very simple way; I generally prefer being able to use jq. IMO both awk and perl are sort of remnants of the age before JSON became the standard text-based structured data format. We used to have to write a lot of dinky little regex-based parsers in Perl to extract data. These days we likely get JSON and can operate on actual data structures.

    I tried nu very briefly but I’m just too used to POSIX-ish shells to bother switching to another model. For scripting I’ll use #!/bin/bash with set -eou pipefail but very quickly switch to Python if it looks like it’s going to have any sort of serious logic.

    My impression is that there’s likely more of us that’d like a less wibbly-wobbly, better shell language for scripting purposes, but that efforts into designing such a language very quickly goes in the direction of nu and oil and whatnot.

    • Overspark@piefed.social
      link
      fedilink
      English
      arrow-up
      0
      ·
      18 days ago

      nu 's commands also work on JSON, so you don’t really need jq (or xq or yq) any more. It offers a unified set of commands that’ll work on almost any kind of structured data.