49

I love dired, but sometimes (particularly when filming screencasts) I want to see the tree-structure of a directory and its children, a la the tree(1) command. Is there a tree-oriented directory browser for Emacs?

3
  • Pretty sure ecb can do this.
    – c-o-d
    Sep 28, 2014 at 21:34
  • 2
    @EdgarAroutiounian If that's the case, I recommend making an answer out of it :)
    – Trevoke
    Sep 29, 2014 at 12:15
  • Although it isn't a folding tree filemanager, I would recommend ranger.el! If you don't like the Miller columns you can easily switch to minimal ranger mode (deer).
    – lupl
    Jun 17, 2021 at 7:25

7 Answers 7

27

Additionally you can use dired-subtree from dired-hacks repo.

Here you have short demo and screenshot from my setup where I press i to drill down folder and ; to go back.:

  (define-key dired-mode-map "i" 'dired-subtree-insert)
  (define-key dired-mode-map ";" 'dired-subtree-remove)

dired-subtree

PS I'm also aware of direx which looks like that: direx:

3
  • I've tried dired-subtree but the tree structure wasn't as visually apparent as I was looking for. Direx looks perfect tho, I'm gonna go try it.
    – Avdi
    Sep 29, 2014 at 22:40
  • 1
    I'm this one because the suggestion of Direx looks ideal for my use case of putting a directory tree visualization front and center. That's not to discount @keelerm's excellent suggestions though.
    – Avdi
    Sep 29, 2014 at 22:49
  • You can get equivalent functionality using one key binding: (define-key dired-mode-map "i" 'dired-subtree-toggle). I like to map it to "C-c i" though since dired also does insert subdirectory using "i".
    – Joe
    Oct 6, 2019 at 20:47
25

There are a couple of options for this.

You can check out dirtree, which is based on dired.

There is also an emacs port of vim's NERDTree called neotree.

Both are excellent packages, though I tend to favor neotree as it has convenient bindings to let me create and delete files and directories. I do not believe dirtree has this support, though I could be wrong. It has been a while since I last used it.

1
  • Thanks, while direx looks to be ideal for my immediate need, you've reminded me that I need to spend some time with neotree.
    – Avdi
    Sep 29, 2014 at 22:50
19

Have you ever tried Emacs' M-x speedbar? :-) before installing some new package I'd try an inbuilt solution...

Update 2020-01-10

Actually I'm using now dired-sidebar which is available via Melpa.

1
  • 3
    …and one more upvote for suggesting a builtin. Sep 12, 2017 at 18:20
11

You can invoke dired with an argument, ie. C-u C-x d and after prompting for the directory it will also let you modify the switches passed to ls. Add R and dired will recursively list all sub-directories, each in it's own section.

If you only want to see the contents of some sub-directories, press i when the point is on a directory name.

You can also use the find-dired command, with or without switches. Instead of showing sub-directories in their own section it prints the full path of each file. You can toggle showing file details with ( so that the long paths fit horizontally on screen.

These are all built-in.

4

There is also ztree. I use it when I need to take a look at directory structure, although usually I use vanilla Dired for all other things.

2

Treemacs works. It allows you to have a treelike structure.

2
  • Is this an answer or a question (two questions)? It is pretty-much a link-only answer, if it is an answer. As such, it risks being deleted. See emacs.stackexchange.com/help/how-to-ask.
    – Drew
    Nov 18, 2017 at 0:13
  • 1
    @Drew, fwiw I think this is just a language/interpretation issue. Treemacs is an absolutely acceptable suggestion to the OP's question. Jan 6, 2018 at 4:08
1

Take a look at sidebar.el.

As the repo said, it is is a customizable file explorer with git integration, but not only that. You can also get the list of buffers and your maildirs with mu4e.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.