I wrote recently about how to use the command
dired+ to open a recently used directory in dired. It turns out I had misunderstood what that command was for – it is intended to create a dired buffer containing a list of recently used directories, which is not exactly what I wanted.
Here is a function to give you a list of recent directories, using
ivy (part of swiper) to narrow it dynamically, and then open the selected one in dired.
;; open recent directory, requires ivy (part of swiper) ;; borrows from http://stackoverflow.com/questions/23328037/in-emacs-how-to-maintain-a-list-of-recent-directories (defun bjm/ivy-dired-recent-dirs () "Present a list of recently used directories and open the selected one in dired" (interactive) (let ((recent-dirs (delete-dups (mapcar (lambda (file) (if (file-directory-p file) file (file-name-directory file))) recentf-list)))) (let ((dir (ivy-read "Directory: " recent-dirs :re-builder #'ivy--regex :sort nil :initial-input nil))) (dired dir)))) (global-set-key (kbd "C-x C-d") 'bjm/ivy-dired-recent-dirs)