1. 24
  1. 10

    Not sure if linking to a top-level of Github repos is the best way to let someone know about something…

    Here’s some other discussions about Nushell:

    1. 8

      Huh. I’m not sure how that happened. I intended to link to the main site here: https://www.nushell.sh/

      Maybe a moderator can update the link?

    2. 7

      …so how do I write a function? :D

      1. 3

        They’re still working on scripting support. Right now, nu only supports interactive use and simple statements.

      2. 4

        Did all this stuff need to be a shell? I mean it replaces ls, a command that lists items in the current directory (in my experience, sorted by name by default), with a command that needs to be piped into sort-by name, which means you need to know “name” is a field, making ls equally or more complicated than piping it into sort. And instead of a series of rows you get an unnecessary ascii table. A lot of what this shell seems to do with where, sort-by, get and the like are simply achieved with awk. Can someone explain this project to me? I really must not get what it’s trying to achieve, what is being done that a moreutils-style package couldn’t do?

        1. 5

          The idea is precisely to not have to use languages like AWK to do stuff that requires structure. Traditional Unix shells only work with plain text, however some shells like PowerShell work with objects instead of plain text (plain text is just a special type of object), which are more composable on its own.

          1. 2

            I totally get structure, which is achieved by tools like relational pipes, there is an actual structure transferred from process to process; this appears to be as simple as column names

            1. 4

              It’s certainly not limited to column names - it’s a stream of nestable, typed values. Take du for instance:

              nushell(master)> du crates
              ───┬────────┬──────────┬──────────┬─────────────────
               # │ path   │ apparent │ physical │ directories
              ───┼────────┼──────────┼──────────┼─────────────────
               0 │ crates │   2.0 MB │   2.3 MB │ [table 23 rows]
              ───┴────────┴──────────┴──────────┴─────────────────
              

              path is of type PathBuf, not just a string, apparent and physical are of type Bytes, and directories is a nested table with 23 rows of its own:

              du crates | get directories
              ────┬─────────────────────────────┬──────────┬──────────┬────────────────
               #  │ path                        │ apparent │ physical │ directories
              ────┼─────────────────────────────┼──────────┼──────────┼────────────────
                0 │ crates/nu_plugin_sys        │  13.1 KB │  15.4 KB │ [table 1 rows]
                1 │ crates/nu-plugin            │  13.7 KB │  14.8 KB │ [table 1 rows]
                2 │ crates/nu-test-support      │  19.6 KB │  43.0 KB │ [table 1 rows]
                3 │ crates/nu_plugin_str        │  28.7 KB │  24.1 KB │ [table 1 rows]
              ...
              
              1. 2

                But what’s the difference between a “nested table” with 23 rows and a regular file with 23 lines? UNIX had relational database style operators like join over 40 years ago. They are still in coreutils today. I have literally no idea what this achieves

                1. 2

                  Ability to do something vs ability to do something in an easy and consistent way

                  1. 2

                    But what’s the difference between a “nested table” with 23 rows and a regular file with 23 lines?

                    The nested table is an explicit data structure with fields of structured data types, including other tables, and your regular file with 23 lines is a flat ad-hoc blob of bytes that isn’t going to safely, cleanly, or sensibly encode something as trivial as a filename.

                    You can’t safely or easily extract directory names from du:

                    -% du
                    1033    foo bar
                    lolwtf
                    
                    

                    And doing anything with these looks like, erm, “fun”:

                    -% ls
                    foo\ bar\nlol\001wtf\n/
                    -% gls
                    'foo bar'$'\n''lol'$'\001''wtf'$'\n'
                    

                    But this works just fine:

                    > du | get path | rm --recursive $it
                    deleted /home/freaky/code/nushell/x/foo bar
                    lolwtf
                    
                    

                    And so does this:

                    > ls | get name | rm --recursive $it
                    deleted /home/freaky/code/nushell/x/foo bar
                    lolwtf
                    
                    
          2. 3

            I think there is still a decent amount work to do here yet. For example, it doesn’t seem possible to effectively cd from the results of a pipeline, or if it is, I haven’t managed to figure that out. It’s probably possible via a plug-in.