4 ms·
Emacs dired-mode as a file manager
- paulyy_y 1y agoThe insanity of trying to shoehorn everything into emacs, even calling it an OS, is purely beyond.
- snapdaddy 1y agoHow many editors can you think of that don't do any (strictly) unnecessary file operations, e.g. renaming files? The author's problem is that Emacs is just really good at it, so he wants to use it more.
- bigdict 1y agoOnce you realize that elisp is a better shell programming language than bash, it ceases to appear insane.
- hollerith 1y agoI much prefer them to the people that try to shoehorn everything user-facing into the browser.
- internet_points 1y agos/browser/llm
- tadfisher 1y agoEmacs is a shell, not an OS. It's an extremely customizable and programmable shell that works with many third-party utilities, but it's still a shell.
- rbc 1y agoI'd call it more than a shell. It's more like a text oriented Lisp (Emacs Lisp to be specific) runtime environment with built in editing, interpretation, compilation, and debugging tools. It's also been a popular home for numerous applications that have found lives of their own, far beyond editing text.
- hollerith 1y agoI like to call it a generalized interface to information. The web of the early 1990s could be called the same thing, but not the modern web, which is more like a "generalized experience-delivery platform with an old much-simpler generalized interface to information at its core".
- TacticalCoder 1y agoAn OS may be too much but, as a proof of concept, there are people who have been running Emacs as PID 1. And I don't mean in an OCI container (we're used to have only one process there): I mean on the bare metal, with Emacs being PID 1. A bit radical but it's been done.
- timewizard 1y agoIt gives me fewer reasons to leave Emacs. Which increases my productivity. There's very little 'mental context switch' delay since it's all the same tool with the same interface.
- SoftTalker 1y agoMy file manager is the shell and the utilities like cp, mv, rm, find, xargs, grep, etc. Have never felt the need for anything beyond that.
- trey-jones 1y agodired-mode is fairly necessary in emacs to preserve the continuity of what you are editing. For example, if I'm editing a file called originalfilename.txt, and I decide it should be called newfilename.txt, I can mv originalfilename.txt newfilename.txt in the terminal and it's all good, but you're still editing the buffer originalfilename.txt in emacs and if you save it you will have a new file with that name. Using dired to change the filename updates all the buffers that are using that file. dired gets some hate, I think because it creates a lot of buffers and they tend to stick around, but it's never bothered me.
- partdavid 1y agoI'm also an emacs user in the habit of using the shell for file management, and I just deal with this mismatch. It hasn't been annoying enough for me to solve by switching to something else. But then again, I guess I don't do a lot "file management", whatever that really means.
- trey-jones 1y agoI think it's pretty easy to learn to just M-x dired compared to however you switch to terminal in these cases and probably would be worth it. I guess we're using this "file management" term to mean delete or move - it's whatever you want it to be.
- partdavid 1y agoI suppose (strictly speaking it's easier to C-x o into the terminal frame or Alt-tab to the terminal window; but it's negligble either way), but the "cost" is not really about invoking it, but learning it for an unclear payoff. Everything is different for me in dired window, navigation doesn't work the way it does in a text buffer, you have to drill down and up in steps. On the occasion where I'm even tempted to interact with a list of files, it seems easier to do git diff development --name-only | gci | ocgv | sco -exp fullname | xargs e And then pick from the list and boom, they're all in buffers. I mean, sure, that's because I set it up that way (in particular the emacsclient wrapper e, which does other smart things like find the TRAMP server, etc. etc.), and presumably there's an equivalent in dired but the distance from here to there seems paved with a lot of clunkiness. The nice thing about using the shell is that I can add to or subtract from these expressions and manipulations at will.
- susam 1y agoI 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
- 90s_dev 1y agoThe one thing I miss about dired-x is being able to edit multiple filenames simultaneously in the same way you do edit a file using multiple cursors, and commit the changes all at once. Can someone make that work in Windows Explorer or VS Code please?
- perihelions 1y ago> "Opening them from dired-mode already puts them into emacs, so" This also works globally with #'find-file-at-point (which isn't bound to a hotkey by default, but should be: this is one of my most satisfying hotkeys. That function opens any filepath appearing as a string, in any context, in the working directory of that context—filepath strings in files, and filepath strings as outputs from shell commands, being the top two). (It's like converting every file reference into a clickable URL—only, implicitly).
- mrechsteiner 1y agoThis works really well together with Embark (https://github.com/oantolin/embark https://github.com/oantolin/embark) as well. C-. then RET to open the file, or any other action you'd like to perform on it.
- ruricolist 1y agoIf you just do C-x C-f, M-n to get the "next completion" gives you the file at point.
- ww520 1y agoIn dired-mode, I want to have a split view of the directory listing on the left window and to quickly browse the content of each file on the right window. The default file visit command keeps opening a new window for each file which needs closing. It's really annoying. I put the following in init.el file and bind it to a key. It loads the current file under the cursor in the next existing window on right, on left, above, below, or opening a new window as needed. ;; In dired mode, visit the file at the cursor in the right/below/left/above window. (defun my-dired-display-direction () (interactive) (let* ((file-or-dir (dired-get-file-for-visit)) ;; get the file at cursor (buffer (find-file-noselect file-or-dir))) ;; load the file into a buffer (let ((window ;; figure out the window to use (cond ((get-buffer-window buffer (selected-frame))) ((window-in-direction 'right)) ;; try window in each direction ((window-in-direction 'below)) ;; and default to right ((window-in-direction 'left)) ;; if no window found. ((window-in-direction 'above)) (t (split-window (selected-window) nil 'right))))) (window--display-buffer buffer window 'window nil) window)) ) ;; Bind ctrl-o to display at direction. (define-key dired-mode-map (kbd "C-o") 'my-dired-display-direction)
- skydhash 1y agoAn alternative workflow I use is the dired-view-file bound to 'v' to have a read-only buffer for the file which you can scroll through with <space> and other such keys. Then you can use 'q' to close the buffer and 'e' to edit it.
- ww520 1y agoYes, that works but the view window takes up the whole frame. I want the dired window remains and the cursor/focus to remain in the dired window so that I can go down the file list and see the file content on the other window. Ctrl-n and ctrl-o are all I need to do.
- skydhash 1y agoI got you. I like to be focused on a single thing so whatever is in front of me is relevant to the current task: Either selecting files or viewing them. So I've never been a fan of the file explorer windows/dock in most editors and IDEs. In Vim, I use vinegar, which bind the minus key to display the file's directory in netrw and in netrw, go up.
- entropie 1y agoI use dired for a long time now and at first it felt a bit weird but not anymore. The ultimate killer feature is wdired [1] that make the dired buffer writeable and you can edit text/filenames/permissions like in any other emacs buffer and commit the changes with C-c C-c. 1: https://www.gnu.org/software/emacs/manual/html_node/emacs/Wdired.html https://www.gnu.org/software/emacs/manual/html_node/emacs/Wd...
- anthk 1y agoLike vidir for any Unix tools, you can get vidir from the 'moreutils' package. A must have under the Unix toolchest, among entr and friends.
- ews 1y agoThe most amazing part of guix (and nixOS) is that you can just copy that piece of code into your home-config.scm and have it running in a few seconds. It's pretty mind blowing.
- julienchastang 1y agowdired-change-to-wdired-mode, FTW! :-) An extremely cool feature is dired buffers are editable for changing file names and permissions. You can even use this feature, en masse, with other features like rectangle edit.
- tcoff91 1y agoCan you copy a line and paste it in a different directory to copy a file? Oil.nvim provides an incredible experience for managing files. It'll even use the LSP to fix imports if you move files from place to place.
- julienchastang 1y agoI've never tried that but copying files via two different dired buffer is trivial. It is also really useful for copying files to and from remote hosts via tramp. (If copying large files in this manner look into rsync versus ssh.) Here is my .emacs if you want to see it: https://github.com/julienchastang/dotemacs/blob/master/settings.org https://github.com/julienchastang/dotemacs/blob/master/setti.... It is a continuous work in progress.
- teddyh 1y agoSlight nitpick: It’s no longer called a “MIME Type”, it’s now called an “Internet Media Type”.
- shwouchk 1y agomy absolute favorite feature of dired is rw mode (^x ^q) - edit your dir like a normal text file. use regex replacement, macros with counters, multi cursor - whatever you like. See the result of your edits, commit bam. much more fun than piping find through something