5

helm-find is

Preconfigured ‘helm’ for the find shell command

I need the same functionality with ivy/counsel.

2 Answers 2

3

Maybe something like:

(ivy-read "File: " (directory-files-recursively default-directory ""))

You might also try this (adapted from http://oremacs.com/swiper/#example---counsel-locate):

(defun counsel-find-function (str)
  (if (< (length str) 3)
      (counsel-more-chars 3)
    (let ((cmd
            (format
              "find %s ! -readable -prune -o -iname \"%s*\" -print"
              ; NOTE: some versions of `find' may require parentheses,
              ; like this: \( ! -readable -prune \)
              default-directory
              (counsel-unquote-regex-parens
              (ivy--regex str)))))
      (message "%s" cmd)
      (counsel--async-command cmd))
    '("" "working...")))

;;;###autoload
(defun counsel-find (&optional initial-input)
  "Use GNU find, counsel and ivy  to present all paths
   in a directory tree that match the REGEX input"
  (interactive)
  (ivy-read "Find: " #'counsel-find-function
            :initial-input initial-input
            :dynamic-collection t
            :history 'counsel-find-history
            :action (lambda (file)
                      (with-ivy-window
                        (when file
                          (find-file file))))
            :unwind #'counsel-delete-process
            :caller 'counsel-find))

(counsel-set-async-exit-code 'counsel-find 1 "Nothing found")
1
  • I end up using fzf --no-sort --filter='%s' | tac.
    – fhdhsni
    Commented May 17, 2017 at 9:21
8

The counsel equivalent of helm-find is counsel-file-jump.

See also counsel-dired-jump and John Kitchin's answer for suggestions on writing a custom function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.