Repository navigation
How to pass this fd command to consult? #1338
|
Disclaimer: not a programmer (only use Emacs for org-mode) How to pass the following Basically, I want to trigger a key to fuzzy select list of matching files (important Emacs config files) to open as file buffer. I believe Any help is much appreciated. I might also want to combine the results of this command and another fd command together as one set of files to select with |
Replies: 1 comment
|
Put this in your config: (defun my/config-files ()
"Return a list of my important Emacs config files."
(mapcar #'abbreviate-file-name
(process-lines "fd" "-d" "1" "\\.el$"
(expand-file-name "~/.config/emacs")
(expand-file-name "~/.config/emacs/elisp"))))
(defun my/open-config-file ()
"Fuzzy-pick one of my config files and open it."
(interactive)
(find-file (completing-read "Config file: " (my/config-files) nil t)))
(keymap-global-set "C-c e" #'my/open-config-file)Now Notes:
Combining several fd commands, as you mentioned: just (defun my/config-files ()
(mapcar #'abbreviate-file-name
(append
(process-lines "fd" "-d" "1" "\\.el$"
(expand-file-name "~/.config/emacs")
(expand-file-name "~/.config/emacs/elisp"))
(process-lines "fd" "-e" "org" "." (expand-file-name "~/org")))))(If you're on Emacs older than 29, use |
consult-fdis designed for interactive searching, where what you type becomes the fd pattern. For a fixed command like yours, it's simpler to runfdonce and hand the results tocompleting-read. Consult/Vertico (or whatever completion UI you use) gives you fuzzy selection automatically.Put this in your config: