6 ms·
I didn't see this mentioned in the article, so I thought I would mention it here: Dired stands for directory editing. One of my favourite features of Dired is
by susam 1y ago
I didn't see this mentioned in the article, so I thought I would mention it here:
Dired stands for directory editing.
One of my favourite features of Dired is the ability to mark or unmark multiple files in a variety of ways: manually, using repetition counts, or with regular expressions. This can be done fluidly and spontaneously as we browse and inspect files. Once we're satisfied with our selection, we can perform bulk operations on them such as copying, moving, deleting, changing permission bits, compressing the marked files, etc.
It's a bit like how we can use a GUI desktop environment to mark multiple files and then perform bulk operations on them. This is something we cannot easily do on the shell with the standard Unix utilities. But we can do all of this from within Emacs using very concise sequence of keystrokes and muscle memory.
Further, unlike most GUI desktop environments, every Dired interaction is scriptable, recordable, and replayable. I mean every operation or key sequence in Dired is available as an Elisp function, so we can script repetitive tasks by writing small Elisp snippets. Or, alternatively, we can have Emacs record the repetitive actions as keyboard macros, which we can then replay as many times as needed. I no longer have to worry whether the underlying GUI desktop environment supports these features or not because I know Emacs does and I can just use Emacs to browse my system.
And that brings me to another important benefit of using Dired: my muscle memory for Dired is transferable across a wide variety of systems and environments. It doesn't matter whether I'm working locally or logged into a remote shell, or whether I'm on macOS, Xfce4, KDE, etc. I can browse and edit my files and directories in exactly the same way using the same muscle memory and the same set of Dired commands, key sequences, and features!
A couple of years ago, I used to host Emacs book club meetings. I've kept some notes on directory editing with Dired from those sessions here: <https://susam.net/cc/mastering-emacs/ch06.html#dired https://susam.net/cc/mastering-emacs/ch06.html#dired>.
- sixtyj 1y agoSo it is similar to Total Commander, but in editor. Or Double Commander…
- mimischi 1y agoJust that it’s all done from the comfort of the editor one knows and loves, with the same key binding and semantics that at there, whether you edit files in fired, write code, a commit message or an email. Not to get too deep into this, but there’s this warm fuzzy feeling of not having to use /yet another different app/ that’s ever so slightly different to the optimal workflow you have otherwise
- nothrabannosir 1y agoOne difference (I assume?): it’s programmable. It’s a directory editor written in the same VM in which the editor (Emacs) is written. This makes it compostable with your existing IDE toolset of macros, plugins, hotkeys, etc. For example: I never thought of using total commander to augment some custom hotkey in vim. But in Emacs it’s just another set of functions available right there.
- anthk 1y agoGet vidir, and spawn vidir from vim/nvi. It lets you use your editor as an interface to edit directorioes. Pretty fast to delete your files, or rename them.
- JCattheATM 1y ago> One of my favourite features of Dired is the ability to mark or unmark multiple files in a variety of ways: manually, using repetition counts, or with regular expressions. This can be done fluidly and spontaneously as we browse and inspect files. Once we're satisfied with our selection, we can perform bulk operations on them such as copying, moving, deleting, changing permission bits, compressing the marked files, etc. That does sound cool. Emacs sounds like the type of app I would have loved back when DOS was still a thing, but now after using linux for 20 something years, the fact that it can do everything just seems so antithetical to the unix way...even if I could see myself using it, the idea of being so dependent on one app for so much seems so weird to me these days. Guess I'll be sticking with vim and various cli tools until the end of time.
- chungy 1y agoEmacs, and GNU at large, never cared for Eric Raymond's idea of "do one thing and one thing only" being the Unix way. They freely make large do-everything programs.
- JCattheATM 1y agoWhat are some other examples of them doing so aside from Emacs?
- bradain 1y agoEmacs isn't really a follower of the unix philosophy since it's more a hold-over from the world of lisp machines. Emacs also eschews the "everything is a file" philosophy of unix (programs in emacs are just lisp functions) and the idea of storing / transmitting data as plain text, instead using lisp data structures to do that. Lisp itself is kind of antithetical to the unix philosophy too when compared with C. Lisp is presents an extremely simple, totally consistent core that is extremely difficult to implement efficient compilers for. C on the other hand was designed from the outset with the goal of being easy to write compilers for. Requirements for having function prototypes ahead of uses, having all variables declared at the top of a function, etc were done to make it easier to implement. Almost a perfect example of worse is better, really. Check out the unix hater's handbook if you haven't, that sums up pretty nicely the world that emacs hails from.
- forty 1y agoIMO a nice demo of wdired (writable dired) should be enough to convince anyone to switch to emacs :)
- setopt 1y agoNot so sure. I like and use wdired, but `vidir` from `moreutils` is almost as useful and works with any editor. I used it for a decade before trying Emacs and didn’t feel like I was missing out.
- Ferret7446 1y agoSetting aside my personal grudge against moreutils for shadowing GNU parallel with a severely gimped version and generally providing "useless" tools that could be a couple lines of shell copied into your personal config, wdired also allows you to move files/create new subdirectories, change permissions, and change symlink targets. I believe you can also edit multiple directories at the same time (as Dired allows you to insert multiple directories into the same buffer).
- setopt 1y agoI’m pretty sure vidir also handles creating and moving files between subdirectories. I don’t think it handles permissions and synlink targets though. But for sure, these days I prefer dired. I didn’t know about the permission thing, will have to try that out!
- deleted 1y ago[deleted]
- imiric 1y ago> This is something we cannot easily do on the shell with the standard Unix utilities. Huh? All your examples are easily done in a shell. GNU find and fd support regex, xargs can be used for bulk operations, etc. This is more flexible and scriptable than anything dired allows you to do. It might not be immediately easier, but once you grasp how a few basic shell utilities work and how to combine them, using shell history, functions, aliases, and key bindings becomes part of your muscle memory. This workflow is even more transferable across systems and environments. I think dired is convenient if you're already using Emacs and want to do a quick operation, but the shell is far more generally useful in the long run.
- roryirvine 1y agoOn top of that, BSD had a standalone 'dired' in the late 80s and Linux moreutils (not quite a standard, but certainly widespread) contains 'vidir' - which, despite the slightly misleading name, allows you to visually edit a directory with whatever your EDITOR env var points to. As you say, none of them do anything that can't be done with find and xargs (and perhaps a little awk and sed), but they're occasionally handy for one-off operations.
- susam 1y ago> GNU find and fd support regex, xargs can be used for bulk operations, etc. I don't see how this is comparable to arbitrarily browsing through a directory, inspecting files, and manually marking the ones you want to act on. The feature I was describing is more akin to how we browse directories in a graphical desktop environment. I use find, xargs, and similar tools as well, but they don't allow you to casually mark or unmark files and run operations on them later. With these tools, you need a fairly precise idea of what you're targeting. Then you have to write a glob or regex pattern up front, and then execute the command. That's a very different workflow from interactively exploring a directory, making ad-hoc decisions, and selectively marking files as you go.
- imiric 1y ago> I use find, xargs, and similar tools as well, but they don't allow you to casually mark or unmark files and run operations on them later. You might be missing fzf from your toolbelt. Running `fzf --multi` does just that, and allows you to pipe the selection further to anything else you want to do. This is why the shell is a more flexible environment. You don't need to adopt a large monolithic tool or drastically change your workflow to do something which you previously couldn't. You just need to insert another tool that does a single thing well into your existing pipelines, and your workflow can be improved with much less effort.