10 ms·
Show HN: Exa, a replacement for ls written in Rust
- zeekay 12y agoA better ls! I love the git integration.
- hlieberman 12y agoThis is the sort of thing that Rust is meant for. Correct, well-designed low-level tools. It's not an application language; it's a systems language.
- krick 12y agoWell, yeah, maybe, but I've never felt like missing something from ls…
- A_COMPUTER 12y agoxml or json output option would be nice.
- threeseed 12y agoAs more people use it they eventually push higher up the stack. People said Go was just a systems language and we've seen it being used for lots of different use cases.
- TheDong 12y agoGo is fundamentally flawed as a systems language and should never have been used as one. In Go, the GC is opaque and non-optional. In rust it's the opposite. Go fails at one of the fundamental requirements of a systems language. I have not heard many people claim that it really is one.
- oscargrouch 12y agoJust use Go with C or Assembly when its needed, no big deal
- yen223 12y agoYou could do the same with Python, but it would be a stretch to call Python a systems language...
- danieldk 12y agoGo is fundamentally flawed as a systems language and should never have been used as one. The problem may be large binary size (mostly due to the runtime size and static linking). But I don't see why using a garbage collector is a problem for plain UNIX utilities like ls-replacements. In fact, if you are running a Debian or Ubuntu system, a lot of utilities are written in Perl or Python.
- TN1ck 12y agoWorks pretty good! I really like the symbolic-link-preview. But I think it would be better when you just add -l when you enter things like -h, -T, -b, ... or allow an option for that.
- cytzol 12y agoThanks! Years ago I wrote a wrapper for ls that just added colours and did highlighting - but not only was it much slower, I couldn't do things like preview a symlink's path because that information wasn't available in ls's output. So exa was born. And as for automatically adding --long when you use --tree or similar: this is something I've hummed and haahed about, and I'm still not confident that I've done it the best way, so I'm open to suggestions here. It seems that most tools just seem to ignore it if you pass in two conflicting options, or redundant options, and personally I'd much rather have the user always give correct behaviour than potentially get it wrong without knowing. But I'll just have to see how people end up using it.
- fsniper 12y agoI would not joy until exa is tried over a fs with more than a million files. Huge file numbers are a thing now and it is becoming to be an engineering challenge.
- cytzol 12y agoexa can certainly handle a million files. Try running "exa -lRT ~" and watch it produce a tree view of your entire home directory! However, by 'handle', I actually mean 'run without crashing'... if you run that command, it'll be several minutes before it produces any output. exa aligns its output into a tabular format with every column having the same length, which means it actually has to stat and examine every file in the list before it's able to output the first line. This is annoying, but (as far as I know) unavoidable.
- fsniper 12y agoI have not yet looked into the code but if it's using glibc and corresponding getdents code path with suboptimal buffers, it most probably will be slower then ls. more information about the getdents buffer issue: https://www.olark.com/developers-corner/you-can-list-a-directory-with-8-million-files-but-not-with-ls https://www.olark.com/developers-corner/you-can-list-a-direc... Again, beware before downvoting me to oblivion I have not yet looked into the code.
- fsniper 12y agoWith my limited knowledge of rust I've looked into it. Seemingly on unix types of OSes exa uses std::old_fs::readdir, it uses sys::unix::readdir and it uses libc::readdir_r Which would also have the suboptimal getdents buffer issue.
- cytzol 12y agoI don't even have downvote privileges yet! I was unaware of the getdents issue - thanks. However, it is most definitely slower than ls, because I've only tested it on large directories, rather than using it with large directories daily, so I haven't found places to optimise it quite yet. I'm not sure if using Rust will let me avoid that buffer issue, as right now I'm just using the function provided in its standard library.
- joosters 12y agoHow do you pick the colours? The website uses a dark background. If I ran this tool on my terminal (with a white background), would the colours still be readable?
- cytzol 12y agoIt uses the colours you pick in your terminal. I made the website dark because I like that colour scheme, and it's what I look at all day, so copying it for the website was a natural fit :) A few of the filetypes use colours in the 256-colour range, but these should work well too - the grey colour you see for non-existent '-' table cells in the columns view is the exact middle grey value (colour #244) because it's the only one that's guaranteed to work with light-backgrounded terminals.
- themartorana 12y agoForgive me for veering off topic, but would you mind sharing the terminal theme?
- cytzol 12y agoWell, it's originally the Tomorrow Night theme, but I've tweaked all the colours to my own liking (such as making the bold colours slightly lighter) that it's not really officially that anymore. But it's a great theme, and the nearest.
- aurora72 12y agoNot tried yet. Wonder if it's got the option to display the size of directories. On the screenshots, the directories are shown with '-' just like the case with the ls.
- cytzol 12y agoDo you mean recursing into a directory and summing the file sizes of its contents? exa doesn't do this, sorry, but it's something I've been thinking of adding. ls actually displays the 'file size' of the directory, which I've left out, as that number has never benefitted me, ever.
- heinrich5991 12y agoOn ZFS, the number of entries in a directory is reported as the directory's file size in bytes. Pretty nice, but unfortunate if a tool would hide it.
- desireco42 12y agoAm I the only one who, while I think this is awesome utility and idea, find that unless you are Rust enthusiast, likelihood of using it is very low. I think there is a need for such utility, if it could be made in more portable fashion. I am not installing rust just for this.
- wtetzner 12y agoIf the binary could be distributed, then there's no reason you'd need to install Rust to use it.
- desireco42 12y agoOK, yes, that is what I would like to see. Maybe if it would show up in homebrew, then it would be good to install.
- glesica 12y agoIronically, doesn't Homebrew build everything from source? So in that case it would end up installing the Rust compiler before building the application... What you want is a binary download, it seems.
- icebraining 12y agoNo, homebrew supports pre-compiled binaries (known as bottles).
- bede 12y agoAlthough many packages are still source only, Homebrew has an initiative for packaging (or 'bottling') larger tools into binaries for convenience. It can always be overridden with --build-from-source
- cytzol 12y agoI'd really like for that to happen (compiling to a standalone binary is one of the reasons I picked Rust), but I have no idea how to go about doing it...
- deleted 12y ago[deleted]
- Rosales 12y agoWhy should a git integration be part of an ls alternative? In my opinion systems tools should not be bloated by third party libraries. If you need a tool for showing the git status, then write an extra tool for it and keep ls as a clean system tool. Third party libraries add unnecessary complexity to the code.
- kibwen 12y agoI think this is actually most interesting as a demonstration of Cargo's support for "features" (http://doc.crates.io/manifest.html#the-%5Bfeatures%5D-section http://doc.crates.io/manifest.html#the-%5Bfeatures%5D-sectio...), which is a concept I haven't encountered in other package managers before. Is it something that Cargo inherited from Bundler?
- jmgrosen 12y agoThough it's not a package manager, configure scripts have had this for a while -- e.g. ./configure --no-git. Still, it's certainly cool to have it built into Cargo!
- comex 12y agoWhen it comes to Mac system package managers, MacPorts has port "variants" and Homebrew has "options", which are basically the same.
- nathan7 12y agoI'd argue that they all derive from, and are quite similar to Portage's USE flags.
- zedpm 12y agoI wonder if it's a good thing or a bad thing that I've never considered, even for a moment, replacing a tool like ls. My first reaction was that it's hubris to think "ls isn't good enough for me, I'll make something better." A bit more reflection has almost convinced me that it's a very good thing that people are always thinking and working on ways to improve things, even something that's taken for granted. On a tangential note, I learned something new and thought that a few other folks might find this of interest: In the screenshots, we see a file with the name "Licence", which to my American eye looked like a typo. On further investigation I found out that "In British English, Canadian English, Irish English, Australian English, and New Zealand English the noun is spelt licence and the verb is license."[0] [0] https://en.wiktionary.org/wiki/licence https://en.wiktionary.org/wiki/licence
- igravious 12y agoIndeed. To address your first point. If we can't even question the most basic of our tooling then we'll just inhabit a stasis that may be just a local optimum. To address your second point. The way I think these licence/license words should go is - think of advice/advise. The verb's got the 's', the noun's got the 'c'. Am I wasting my time in actually caring about shit like that? Probably. But that's how I'm wired.
- bhrgunatha 12y agoAlso practice/practise - a doctor's practice / practise the piano. I don't think it's a waste of time, but language is fluid. Sometimes it changes very rapidly and sometimes slowly, but it's never static. Since the US uses a single spelling for both (and most of the world defaults to using US English) my guess is that the distinction will vanish eventually. I'm slowly learning not to care about these distinctions when it comes to English, as long as the meaning is clear. The closer you look, the fuzzier language becomes - even in the UK or US alone, there are vast differences in the way it's used.
- ehamberg 12y ago… and advice/advise and prophecy/prophesy. For some reason, only the latter has kept the difference in spelling between the noun and the verb in American English.
- fiatjaf 12y agoIt seems awesome, specially the --tree option. I would love to try it, but Download and install Rust Nightly for your platform. Install libgit2 and cmake using your favourite package management system (or pass --no-default-features to the next step) Run git clone https://github.com/ogham/exa.git to download the latest version of exa. Run cargo build in the new directory to compile exa. Move the resulting target/exa executable into a directory in your $PATH, or add an alias for it in your shell.
- spullara 12y agoThat all just takes a couple minutes.
- gkya 12y agoBut what? This is some code that some dude wrote and published courteously open-source, it's written in a rather-newborn language and it is for computer-savvy users. Were you expecting a binary installer?
- fiatjaf 12y agoI wasn't. I am not complaining, just saying that there is too much friction in all this. Happens with every programming language.
- username223 12y agoThis would make some sense if it were backward-compatible with normal "ls" for basic things like "ls -l". That way, people could alias "ls" to "exa" and not break too many things. But it drops the group and adds Git markers (which are only occasionally relevant), so I don't see myself trying this.
- indiv0 12y agoA similar, but more broadly scoped project is uutils/coreutils [0], which is a cross-platform re-write of the GNU coreutils in Rust. IMO, both the coreutils project and Exa are interesting for the same reason: they provide an example of Rust is one of it's niche environments - low level tooling. [0]: https://github.com/uutils/coreutils https://github.com/uutils/coreutils
- zobzu 12y agoslightly overkill on the coloring ;)
- EpicDavi 12y agoI am using it right now and it is great! My only complaint is that it is a lot easier to type `ls` than `exa` :) (all the letters are on different key rows with the same hand)
- ludamad 12y agoJust symlink it as 'ls' and put it in your path :-)
- _-_-_-_ 12y agoIf `e` isn't already used by another command or function in your environment, you could do something like this in .bashrc, .zshrc, or wherever you put your aliases: alias e='exa -1' alias ea='exa -a1' alias ee='exa -hla' Note, that's a number "1" in the first two, and -h here includes the headers, which is different from ls -h, which exa appears to do by default. Other than the one entry per line printing, it's similar to the ubuntu default aliases for ls.
- zkanda 12y agoI just hope that it's backward compatible with ls, as of the moment, it's not a replacement.
- whyever 12y agoIt's not a drop-in replacement, it's an alternative.
- Animats 12y agoIt would be useful to re-implement the basic UNIX utilities (at least the ones in BusyBox) in Rust. But without all the extra bells and whistles this program has. Lots of embedded systems need a reliable set of tools. An exploit was discovered in "files" recently. Somebody put a decoder for Linux executable files in it, creating a security hole.
- dbaupp 12y agoWhat is 'files'?
- scintill76 12y agoGNU "strings" may have been meant, as it had this issue recently.
- whyever 12y agoThere is uutils [1], which I believe is doing exactly what you are saying. [1] https://github.com/uutils/coreutils https://github.com/uutils/coreutils
- 59nadir 12y agoI find it interesting that so many are disparaging this for not being backwards compatible, etc., when there is simply no need. The title of the post clearly states it's a replacement for ls, so why should it be backwards compatible? It's not like everything everyone ever makes has to be a perfect fit in every capacity. A guy made a replacement for 'ls' as a fun thing to do in a language he likes. We make toys all the time and if you don't you probably just don't even like programming. The fact that he'd share this with us because he thought other people might be interested is precisely why places like these are good. We might as well just start disparaging every posted project for not being a solution to starvation around the world if we're going to condemn everything that isn't an immediate step 'forward'. Let people make things they think are neat and try to see the positive side of things instead. If someone's selling you a product I can see this behaviour being warranted, but when someone is trying to show you something they made because they think it's neat, you don't jump on it as if he's trying to change the world with it.
- cogburnd02 12y ago> ...so many are disparaging this for not being backwards compatible...there is simply no need...it's a replacement for ls, so why should it be backwards compatible? Because unless someone feels like editing every script or tool that makes use of ls, then it cannot be used as a replacement, i.e. You'll have to have both ls and exa on your hard drive instead of just exa. Also, people are used to the options of ls, and backwards-compatibility (in the form of a shell alias) is one less barrier to entry.
- 59nadir 12y ago> Because unless someone feels like editing every script or tool that makes use of ls, then it cannot be used as a replacement It can be used as a replacement just fine, just not if you symlink/alias 'ls' to 'exa', which I don't see as relevant. 'fish' is a replacement for bash, but I don't remove bash because of having it and I still have plenty of scripts using bash. It's just that my personal usage is exclusively with fish. > You'll have to have both ls and exa on your hard drive instead of just exa. Yes. I don't think this is a problem. > Also, people are used to the options of ls, and backwards-compatibility (in the form of a shell alias) is one less barrier to entry. I agree that it is a barrier to entry, yes, but this is clearly a toy created just to have fun with a language and make something that also happens to be fairly useful. It's not meant to take over the world, as far as I can see.
- knowledgesale 12y agoAnother alternative is lsp: https://github.com/dborzov/lsp https://github.com/dborzov/lsp Unlike exa it fully supports Windows and does not have any external dependancies (as it is written in Go, everything is included already).
- deleted 12y ago[deleted]
- on_and_off 12y agoIt is very promising but sadly the alignment of the column mode looks very buggy at the moment.
- on_and_off 12y agoActually, I just updated the repo and rebuilt exa and this issue is gone. As soon as the integration with gitlib2 becomes fast enough, this will be a perfect ls replacement.