/ripgrep-dired

Integrate ripgrep to Emacs find-grep-dired and rgrep.

Primary LanguageEmacs Lisp

ripgrep-dired

About

“ripgrep-dired” is Emacs package, which provide 2 tools related to rg https://github.com/BurntSushi/ripgrep:

  1. The command rg-dired is used to find the matched file list by rg, and output the result to dired mode, as similar as “find-grep-dired”.
  2. The command rg-grep is used to do grep on files, and handle the result by using the way that used by built command “rgrep”.

Run the command “rg-dired”

  1. Input regular grep for search

    image/About/2020-12-26_14-56-28_screenshot.png

  2. The result will be in dired mode, as same as “find-grep-dired”

    image/About/2020-12-26_14-57-35_screenshot.png

  3. Run from helm-find-files

    image/About/2020-12-26_15-05-23_screenshot.png

Run the command “rg-grep”

  1. Input args for rg

    image/About/2020-12-26_15-01-29_screenshot.png

  2. Result

    image/About/2020-12-26_15-02-29_screenshot.png

  3. Run from eshell

    image/About/2020-12-26_15-04-35_screenshot.png

  4. Run from “helm-find-files”

    image/About/2020-12-26_15-05-23_screenshot.png

Installation

pre-require

  1. Please intall https://github.com/BurntSushi/ripgrep firstly, and make sure the command “rg” in the system path.
  2. Intall Emacs package “pcre2el”

install

Clone this git repo to “${user-emacs-directory}/packages/ripgrep-dired”, and add folowing lines to Emacs config file:

(use-package ripgrep-dired
  :defer t
  :ensure nil ; it is github package
  ;; If the path is relative, it is expanded within `user-emacs-directory'
  :load-path "packages/ripgrep-dired"
  :init
  (let ((pkg-name "ripgrep-dired"))
    (ignore-errors
      (package-generate-autoloads pkg-name
                                  (expand-file-name (concat "packages/" pkg-name)
                                                    user-emacs-directory)))
    (load (concat pkg-name "-autoloads.el")))
  )

Usage

  1. in “M-x”, run the command “rg-dired”, or “rg-grep”.
  2. in eshell, run the command “rg” for “rg-grep”
  3. in helm-find-files, select the action “find dired by rg”, or “grep by rg”