Use ivy to open recent directories

  |   Source

The recent directories include parent directories of opened files in Emacs and the directories accessed in Bash shell.

I used fasd to get the list of directories in shell. Fasd "offers quick access to files and directories for POSIX shells".

Here is my setup,

(require 'ivy) ; swiper 7.0+ should be installed

(defun counsel-goto-recent-directory ()
  "Open recent directory with dired"
  (interactive)
  (unless recentf-mode (recentf-mode 1))
  (let ((collection
         (delete-dups
          (append (mapcar 'file-name-directory recentf-list)
                  ;; fasd history
                  (if (executable-find "fasd")
                      (split-string (shell-command-to-string "fasd -ld") "\n" t))))))
    (ivy-read "directories:" collection :action 'dired)))

Screenshot:

ivy-recent-directory-nq8.png

Comments powered by Disqus