9

I often have many dired buffers open, including some for folders that have identical names. Occasionally, this causes me to switch to the wrong one, so I am looking for a way to fix this.

Currently, if I have multiple identically-named folders open in dired, then my buffer list looks something like this:

foo
foo<2>
bar
foo<3>
bar<2>

I would like to include the full path (or some portion of it) in the buffer name so I can see which folder I am actually switching to. I would prefer to do it like this:

foo</full/path/to/foo>
foo</another/path>

and so on. I could also settle for e.g.:

/full/path/to/foo
/another/path/foo

but I would prefer the former, because it will usually be easier to find the buffer I want by folder name first, and full path second. How can this be done?

8

You can get this behavior by using uniquify with the following settings:

(require 'uniquify)
(setq uniquify-buffer-name-style 'post-forward-angle-brackets
      uniquify-min-dir-content 999)

Note however that uniquify works globally, not only on dired buffers.

  • Cool, thanks! I will wait and see if there is a solution that does give a full path before I accept an answer. – Scott Weldon Oct 14 '14 at 0:03
  • 1
    I just added a note about uniquify-min-dir-content, which should help you with that. Note however, that this is a global setting: it applies to all buffers, not just dired buffers! – paprika Oct 14 '14 at 0:06
5

In my .emacs I set full paths for Dired buffers this way:

(add-hook 'dired-after-readin-hook
      (lambda ()
        ;; Set name of dired buffers to absolute directory name.
        ;; Use `generate-new-buffer-name' for vc-directory
        ;; which creates duplicate buffers.
        (rename-buffer (generate-new-buffer-name dired-directory))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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