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?

  • Obin@feddit.org
    link
    fedilink
    arrow-up
    5
    ·
    1 hour ago

    I’m really curious, what’s your favorite shell?

    Emacs eshell+eat

    It essentially reverses the terminal/shell relationship. Here, it’s the shell that starts a terminal session for every command. Eshell is also tightly integrated with Emacs and has access to all the extended functionality. You can use Lisp in one-liners, you can pipe output directly to an emacs buffer, you can write custom commands as lisp functions, full shortcut customization not limited to terminal keys, history search via the completion framework (i.e. consult-history), easy prompt customization, etc.

    There’s also Tramp, which lets you transparently cd into remote hosts via ssh, docker containers, SMB/NFS-shares, archive files, and work with them as if they were normal directories (obviously with limited functionality in some cases, like archives).

    And probably a lot of stuff I’m missing right now.

  • bastion@feddit.nl
    link
    fedilink
    arrow-up
    6
    ·
    edit-2
    3 hours 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.

  • Cat_Daddy [any, any]@hexbear.net
    link
    fedilink
    English
    arrow-up
    8
    ·
    4 hours ago

    I’ve had nushell as my daily driver for a couple years now and I love it. “Made for actual humans to use” is exactly the description I’d give.

  • communism@lemmy.ml
    link
    fedilink
    arrow-up
    16
    arrow-down
    1
    ·
    5 hours 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
      15
      ·
      4 hours 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
        5
        ·
        3 hours 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.

      • esa@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        8
        ·
        edit-2
        4 hours ago

        Yeah, there should be a clear separation between scripts, which should have a shebang, and interactive use.

        If a script starts acting oddly after someone does a chsh, then that script is broken. Hopefully people don’t actually distribute broken script files that have some implicit dependency on an unspecified interpreter in this day and age.

      • communism@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        3 hours ago

        They have !/bin/sh shebangs. /bin/sh is a symlink, in my case to zsh. I like using one language.

        • Aatube@kbin.melroy.org
          link
          fedilink
          arrow-up
          2
          ·
          52 minutes ago

          Hopefully you’re not using the sh language—hopefully you’re restraining yourself from using any of the non-POSIX extensions then

        • ReversalHatchery@beehaw.org
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          2 hours ago

          then your hashbangs are bad. isn’t their point to tell the kernel exactly which interpreter can process it correctly?

    • phantomwise@lemmy.mlOP
      link
      fedilink
      arrow-up
      10
      ·
      5 hours ago

      I don’t really mind having a non-POSIX shell since it doesn’t prevent bash scripts from working, but I get that if you want portability bash is still best since it’ll work mostly anywhere.

      • 4am@lemmy.zip
        link
        fedilink
        arrow-up
        2
        ·
        3 hours ago

        If I can shebang nutshell (assuming all the builtins from bash or even sh work) and pass a flag to remove all the fancy UI-for-humans formatting so that piped commands int eh scripts work, then I think this is incredible.

        Yeah having this installed along side other more “standard” shells is fine I guess, but it looks like maybe it has some neat functionality that is more difficult in other shells? I guess I’d need to read up on it more but having a non-interactive mode for machines to read more easily would be a huge plus for it overall. I suppose that depends on what it offers/what it’s trying to accomplish.

        • Aatube@kbin.melroy.org
          link
          fedilink
          arrow-up
          2
          ·
          46 minutes ago

          The Unicode bars aren’t actually stored; that’s just the graphical representation of the table datatype which you can think of as JSON

  • esa@discuss.tchncs.de
    link
    fedilink
    arrow-up
    28
    ·
    6 hours 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
      5
      ·
      4 hours 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.

    • phantomwise@lemmy.mlOP
      link
      fedilink
      arrow-up
      5
      ·
      5 hours ago

      That’s interesting I hadn’t thought about the JSON angle! Do you mean that you can actually use jq on regular command outputs like ls -l?

      Oil is an interesting project and the backward compatibility with bash is very neat! I don’t see myself using it though, since it’s syntax is very close to bash on purpose I’d probably get oil syntax and bash syntax all mixed up in my head and forget which is which… So I went with nushell because it doesn’t look anything like bash. If you know python what do you think about xonsh? I

      • esa@discuss.tchncs.de
        link
        fedilink
        arrow-up
        3
        ·
        4 hours ago

        That’s interesting I hadn’t thought about the JSON angle! Do you mean that you can actually use jq on regular command outputs like ls -l?

        No, you need to be using a tool which has json output as an option. These are becoming more common, but I think still rare among the GNU coreutils. ls output especially is unparseable, as in, there are tons of resources telling people not to do it because it’s pretty much guaranteed to break.

        • elmicha@feddit.org
          link
          fedilink
          arrow-up
          3
          ·
          43 minutes ago

          There’s jc (CLI tool and python library that converts the output of popular command-line tools, file-types, and common strings to JSON, YAML, or Dictionaries).

    • Overspark@piefed.social
      link
      fedilink
      English
      arrow-up
      12
      ·
      4 hours ago

      Yeah, it has. I think they started out as loving the concepts of PowerShell but hating the implementation, combined with the fact that PowerShell is clearly a Windows-first shell and doesn’t work so well on other OSes (it surprised me a lot to find out that PowerShell even has support for linux).

      nu tries to implement these concepts in a way that’s more universal and can work equally well on Linux, macOS or Windows.

      • ReluctantMuskrat@lemmy.world
        link
        fedilink
        arrow-up
        8
        arrow-down
        1
        ·
        4 hours ago

        Powershell works really well on other OSs now. I use it on MacOS and Linux daily. I might loath MS but Powershell is a fantastic shell and after working with an object-oriented shell I hate going back to anything else.

      • sunbeam60@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        27 minutes ago

        That was the foundational concept in powershell; everything is an object. They then went a ruined it with insane syntax and a somewhat logical, but entirely in practice verb-noun command structure.

        Nushell is powershell for humans. And helps that it runs across all systems. It’s one of the first things I install.

  • Ferk@lemmy.ml
    link
    fedilink
    arrow-up
    16
    ·
    edit-2
    6 hours ago

    I prefer getting comfortable with bash, because it’s everywhere and I need it for work anyway (no fancy shells in remote VMs). But you can customize bash a lot to give more colored feedback or even customize the shortcuts with readline. Another one is pwsh (powershell) because it’s by default in Windows machines that (sadly) I sometimes have to use as VMs too. But you can also install it in linux since it’s now open source.

    But if I wanted to experiment personally I’d go for xonsh, it’s a python-based one. So you have all the tools and power of python with terminal convenience.

    • phantomwise@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      1
      ·
      5 hours ago

      Yeah if you need to work on machines with bash it makes sense to stick with it. Sorry you have to work on Windows… how is powershell compared to bash?

      I don’t know python but xonsh seems really cool, especially since like nushell it works on both linux and windows so you don’t have to bother about OS specific syntax

      • Ferk@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        4 hours ago

        powershell, in concept, is pretty powerful since it’s integrated with C# and allows dealing with complex data structures as objects too, similar to nushell (though it does not “pretty-print” everything the way nushell does, at least by default).

        But in practice, since I don’t use it as much I never really get used to it and I’m constantly checking how to do things… I’m too used to posix tools and I often end up bringing over a portable subset of msys2, cygwin or similar whenever possible, just so I can use grep, sed, sort, uniq, curl, etc in Windows ^^U …however, for scripts where you have to deal with structured data it’s superior since it has builtin methods for that.

  • DasFaultier@sh.itjust.works
    link
    fedilink
    arrow-up
    11
    ·
    edit-2
    6 hours 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.

    • Overspark@piefed.social
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      4 hours ago

      It’s arguably better as a scripting language than as an interactive shell. There are a lot of shell scripts out there that also dabble in light data processing, and it’s not the easiest thing to achieve well or without corner cases. So nu scripts are great if all you need is shell scripts with some data processing.

      nu as an interactive shell is great for the use cases it shines at (like OP’s example), but a bit too non-POSIXy for a lot of people, especially since it’s not (yet) as well polished as something like fish is for example.

      Edit to add that nu’s main drawback for scripting currently is that the language isn’t entirely stable yet, so you better be prepared to change your scripts as required to keep up with newer nu versions (they’re at 0.107 for a reason).

    • Ŝan@piefed.zip
      link
      fedilink
      English
      arrow-up
      7
      arrow-down
      12
      ·
      6 hours 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.

      • TrickDacy@lemmy.world
        link
        fedilink
        arrow-up
        7
        ·
        4 hours ago

        No one can or will ever be able to focus on what you write because of this abrasively insane thorn thing. Maybe find a better way of getting attention?

      • otp@sh.itjust.works
        link
        fedilink
        arrow-up
        9
        ·
        5 hours 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
          3
          arrow-down
          5
          ·
          5 hours ago

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

          • Ferk@lemmy.ml
            link
            fedilink
            arrow-up
            3
            ·
            edit-2
            3 hours 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.

      • Ferk@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        3 hours ago

        I agree completely with that sentiment, I had the same problem, the output of most commands was interpreted in a way that was not compatible with the way Nu structures data and yet it still rendered as if it were a table with 1 single entry… it was a bit annoying.

  • calliope@retrolemmy.com
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    6 hours ago

    I use zsh, mainly because I’ve been using it for a really long time and it felt like an upgraded bash.

    I also have used fish a tiny amount and like the idea but zsh just works for my purposes and I already know how it works.

    nushell looks really cool though!

    I don’t have much occasion to use awk any more but it can be really useful!

    • phantomwise@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      6 hours ago

      I’ve also been using zsh until now, it’s clear it’s a massive improvement over bash. No more accidentally pasting code into the terminal!

      I wasn’t even looking for a new interactive shell, zsh is fine, I was looking for a new language for shell scripts because I’m tired of bash’s legacy quirks… but the interactive nushell was too cool to resist!

      • calliope@retrolemmy.com
        link
        fedilink
        arrow-up
        1
        ·
        4 hours ago

        nushell seriously looks amazing for working with data. I gotta remember it exists the next time I’m doing stuff like this.

        It seems like a nice shell to have around and usable for cases like this regardless!

  • ArseAssassin@sopuli.xyz
    link
    fedilink
    arrow-up
    7
    ·
    6 hours ago

    Love nushell. It’s just about the most practical functional programming language I’ve ever had the pleasure of using.

    I’m using fish as my default shell since it’s more standards-compliant and plays nicer with tools that modify your environment. But any time I need to do more complicated shell scripting, I’m breaking out nushell.

    • Oinks@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      10
      ·
      edit-2
      5 hours ago

      The usual problems with parsing ls don’t happen here because Nu’s ls builtin returns properly typed data. You can work with it in pretty much the same way you would work with it in Python, except that Nu has a composition operator that doesn’t suck ass (|), so you don’t have to write as much imperative boilerplate.

      I have a number of reservations regarding Nu (the stability of the scripting language, unintuitive syntax rules, a disappointing standard library) but this particular argument just doesn’t apply.

      • drspod@lemmy.ml
        link
        fedilink
        arrow-up
        3
        ·
        3 hours ago

        The usual problems with parsing ls don’t happen here because Nu’s ls builtin returns properly typed data.

        Isn’t that the point that the previous commenter was making by linking that answer? I read their comment as “here is why you should use Nu shell instead of parsing ls output.”

      • MonkderVierte@lemmy.zip
        link
        fedilink
        arrow-up
        3
        ·
        2 hours ago

        Yeah, why are linebreaks & co. in names even allowed on file system level? There’s not even something like a restricted mode mount option for most fs.

        • Oinks@lemmy.blahaj.zone
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          34 minutes ago

          There’s an argument to be made that system software like filesystems and kernels shouldn’t get too smart about validating or transforming strings, because once you start caring about a strings meaning, you can no longer treat it as just a byte sequence and instead need to worry about all the complexities of Unicode code points. “Is this character printable” seems like a simple question but it really isn’t.

          Now if I were to develop a filesystem from scratch, would I go for the 80% solution of just banning the ASCII newline specifically? Honestly yes, I don’t see a downside. But regardless of how much effort is put into it, there will always be edge cases – either filenames that break stuff, or filenames that aren’t allowed even though they should be.

  • black_flag@lemmy.dbzer0.com
    link
    fedilink
    arrow-up
    2
    ·
    6 hours ago

    Nushell is great, I should use it again. Gave up on it after I wrote a thing for converting fish completions to their autocomplete system for it and their internal autocomplete didn’t perform anywhere nearly adequately.

    • Overspark@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 hours ago

      Check out carapace. It takes a bit of setup but basically tries to make all the completions work in almost any shell. For me that solved the big step backwards from fish’s completions that nu’s native completions have.