branch: master
commit c38daa31d8aafd4f17226dd6f505b256d1105022
Author: CeleritasCelery <t.mac...@gmail.com>
Commit: Oleh Krehel <ohwoeo...@gmail.com>

    Enable counsel-read-env to work in read-file-name
---
 counsel.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/counsel.el b/counsel.el
index 6521ddd..1b4133c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1748,7 +1748,6 @@ currently checked out."
     (define-key map (kbd "C-DEL") 'counsel-up-directory)
     (define-key map (kbd "C-<backspace>") 'counsel-up-directory)
     (define-key map (kbd "C-M-y") 'counsel-yank-directory)
-    (define-key map "$" 'counsel-read-env)
     map))
 
 (defun counsel-yank-directory ()
@@ -1897,7 +1896,8 @@ Skip some dotfiles unless `ivy-text' requires them."
   "Read a file path environment variable and insert it into the
 minibuffer."
   (interactive)
-  (if (equal ivy-text "")
+  (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)))
@@ -1916,6 +1916,8 @@ minibuffer."
         (ivy--cd-maybe))
     (insert last-input-event)))
 
+(define-key ivy-minibuffer-map "$" 'counsel-read-env)
+
 (defun counsel-find-file-action (x)
   "Find file X."
   (with-ivy-window

Reply via email to