1. 34
  1. 21

    Why would I want my ls to git status?

    1. 17

      Perhaps because many of your filesystem directories are merely ephemeral staging areas for files whose true existence is in a loosely-connected web of Git repositories, eternally recording their history and backing them up around the globe, and so the actual most important thing to know about those files is whether they contain changes that might be accidentally lost.

      1. 6

        Odd, it seems most commenters so far have never pretty formatted their own custom git aliases or added git status/branch to their shell prompt. And power tools like glances? Real users eschew even top and cat /proc directly! </sarcasm>

        The block and hard link counts is great. More transparency into my files and filesystem is welcome!

        1. 4

          Blocks and hard links are already available in ls, as they should be, since its job is to list information about files.

          1. 1

            I did not know that number was the hard link count (man doesn’t say, only info does, so much for rftm). Thank you!

        2. 3

          I looked through the code; the git integration is completely optional. Everything git-related is guarded with a feature flag, so you can disable it at compile time if you don’t like it: https://github.com/ogham/exa/blob/master/src/dir.rs#L81

        3. 8

          I’m not sure I’ll use this directly, but I may come back to the source code if I decide to learn Rust. Small, non-trivial programs are the best example code.

          1. 13

            I wouldn’t say this is a replacement for ‘ls’ at all, because it doesn’t meet any of the POSIX requirements for ‘ls’.


            I would say, this is a alternative way to list directory contents on some UNIX'y platforms, and its interesting to see such work done in Rust.

            1. 2

              I had a similar mental response to the FAQ on Windows support: “Why would you want something which doesn’t play nice with the rest of the PowerShell ecosystem?”

              In both Unix and Windows, we use ls/gci for two different reasons: Standalone and composed with other programs/cmdlets. As a developer of a “replacement,” it’s good to think about both.

              1. 9

                ls is one of those tools I’ve never used in a script. Shell globbing or find are easier and more powerful, respectively; ls occupies a middle ground which is ideal for interactive use but seldom good for scripting.

                1. 4

                  While you aren’t wrong, you’d be surprised how many people reflexively reach for ls in shell scripts.

                  I’ve seen so much like: ls -l | awk '{print $3}' and similar as to make me want to become a monk.

                  1. 3

                    cat foo | grep bar

                    I’m no fan of Unix but c'mon.

                    1. 2

                      I do this all the damn time. Probably because I’m thinking of what file I want before I think of the exact regex I want to search for. Not in scripts though.

                      The issue reminds me of differing grammar structures.

                      • search for a pattern in the file
                      • ファイル内にパターンを探せ

                      They mean the same thing, but in Japanese the word order is totally different. Maintaining structure, it’s something like “in the file, for a pattern, search.”

                      Also, my Japanese is not great, “ファイルにパターンを探せ” or something else may be more correct but the structure is the same.

                      1. 2

                        Sorry to beat a dead horse, but if you do cat foo | grep bar often because you think of foo first, just use <foo grep bar.

                        1. 2

                          Why is this a problem?

                          It’s not unclear; it’s unlikely to slow things down in any sort of meaningful way; it doesn’t do the wrong thing.

                          What makes it more than a purely stylistic preference?

                      2. 2

                        Another favorite type of shell gem I’ve found along those lines:

                        cat blah | grep -v foo | grep -v bar | grep somethingorother

                        I also know someone running SuSE that found out a recent patch broke ksh backtick behavior and not $(). Which makes me all the happier when I can avoid shell.

                        Another I just remembered:

                        cat something | grep foo | wc -l


                        grep -c foo something

              2. 9

                This sounds cool and all, but I think it breaks with the Unix tradition. It seems to be trying to do a lot of things, and not necessarily well.

                1. 3

                  way too flashy as well

                  1. 2

                    If anyone who bashes systemd and installs this need to experience on temporary kernel panic.