5

helm-find is

Preconfigured ‘helm’ for the find shell command

I need the same functionality with ivy/counsel.

Drew
  • 75,699
  • 9
  • 109
  • 225
fhdhsni
  • 693
  • 6
  • 16

2 Answers2

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.

Basil
  • 12,019
  • 43
  • 69
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")
Basil
  • 12,019
  • 43
  • 69
John Kitchin
  • 11,555
  • 1
  • 19
  • 41