diff options
| author | Jakob L. Kreuze | 2022-06-16 21:42:56 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze | 2022-06-16 21:42:56 -0400 |
| commit | b7ce95f056940ac39eaa31f06749934ca75c366e (patch) | |
| tree | c337a8f850b5b4e88993bf8348b12f0e635ef9d5 | |
| parent | c91de3260929bbaf4c6865b8da3b87eeb79fe865 (diff) | |
[ivy] el-patch to allow for TRAMP aliases
| -rw-r--r-- | lisp/quality-of-life.el | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/lisp/quality-of-life.el b/lisp/quality-of-life.el index 09bba46..8514f55 100644 --- a/lisp/quality-of-life.el +++ b/lisp/quality-of-life.el @@ -31,7 +31,34 @@ ;; If I'm typing a file name with capitalized letters, I may be holding shift ;; when I press space. This is a pain in the ass, and I don't use the feature ;; anyway, so I unbind it. - (bind-key "S-SPC" nil ivy-minibuffer-map)) + (bind-key "S-SPC" nil ivy-minibuffer-map) + + :config/el-patch + (defun ivy-magic-read-file-env () + "If reading filename, jump to environment variable location." + (interactive) + (if (and ivy--directory + (equal ivy-text "")) + (let* ((cands (cl-loop for pair in process-environment + for (var val) = (split-string pair "=" t) + if (and val (not (equal "" val))) + if (or + ;; Don't `file-exists-p' on TRAMP stuff + (el-patch-add (string-suffix-p ":/" val)) + (file-exists-p + (if (file-name-absolute-p val) + val + (setq val + (expand-file-name val ivy--directory))))) + collect (cons var val))) + (enable-recursive-minibuffers t) + (x (ivy-read "Env: " cands)) + (path (cdr (assoc x cands)))) + (insert (if (file-accessible-directory-p path) + (file-name-as-directory path) + path)) + (ivy--cd-maybe)) + (insert last-input-event)))) ;; `counsel' is a nice Ivy-based frontend for a couple of interactive commands. |