4

helm-find is

Preconfigured ‘helm’ for the find shell command

I need the same functionality with ivy/counsel.

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")
  • I end up using fzf --no-sort --filter='%s' | tac. – fhdhsni May 17 '17 at 9:21
7

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, privacy policy and cookie policy

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