比如我想快速跳转到我曾经浏览过的一个文件夹(可能不是 Project)。
Helm 支持搜索历史文件,但似乎不支持搜索历史文件夹(有一个功能可以搜索历史文件夹,但是仅限在Session内,重启Emacs记录消失)。
我喜欢终端 autojump 这样的工具。如果 Helm 支持搜索历史文件夹也是不错的方案,可惜目前还没有找到。
想请问大家有什么方案可以实现浏览/快速跳转历史文件夹?谢谢!
比如我想快速跳转到我曾经浏览过的一个文件夹(可能不是 Project)。
Helm 支持搜索历史文件,但似乎不支持搜索历史文件夹(有一个功能可以搜索历史文件夹,但是仅限在Session内,重启Emacs记录消失)。
我喜欢终端 autojump 这样的工具。如果 Helm 支持搜索历史文件夹也是不错的方案,可惜目前还没有找到。
想请问大家有什么方案可以实现浏览/快速跳转历史文件夹?谢谢!
使用 fasd 然后配合 helm 或者 ivy 作为前端就可以了。
感谢,已完美配置。心头之痛解决,可以愉快开启Emacs之旅了:joy: 。
附上配置步骤:
helm和ivy本来就支持浏览之前开过的文件或文件夹的,你开下就好了。我不用helm很久了,忘了哪个设置。 ivy显示历史,途径还挺多的 (请看分隔线下面的。搞错了,这里只显示历史文件,没有文件夹):
M-x counsel-recentf
ivy-switch-buffer
时,已开buffers列表下面添加出历史(setq ivy-use-virtual-buffers t)
(define-key minibuffer-local-map (kbd "C-r") 'counsel-minibuffer-history)
;; ensure recentf-list loaded on startup
(with-eval-after-load 'counsel (recentf-mode))
注:这里用的历史记录不尽相同,这是我曾经问时开的issue:
如果要准确满足你的要求,即只显示历史文件夹,得自定义下:
;; use ivy to open recent directories
;; http://blog.binchen.org/posts/use-ivy-to-open-recent-directories.html
;; https://emacs-china.org/t/topic/5948/3?u=et2010
(defvar counsel-recent-dir-selected "~/")
(defvar counsel-recent-dir-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "TAB") 'counsel-recent-dir-find-file)
(define-key map [(tab)] 'counsel-recent-dir-find-file)
map))
(defun counsel-recent-dir-find-file()
(interactive)
(ivy-exit-with-action
(lambda(c)
(setq counsel-recent-dir-selected c)
(run-at-time 0.05 nil
(lambda()
(let ((default-directory counsel-recent-dir-selected))
;; (find-file counsel-recent-dir-selected)
(counsel-find-file)))))))
(defun counsel-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
:keymap counsel-recent-dir-map
:action (lambda (x) (if (fboundp 'ranger) (ranger x) (dired x))))))
(global-set-key (kbd "M-g h") 'counsel-recent-directory)