Skip to content

Instantly share code, notes, and snippets.

@til
Created October 29, 2014 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save til/fe24eebae7bcf799b08f to your computer and use it in GitHub Desktop.
Save til/fe24eebae7bcf799b08f to your computer and use it in GitHub Desktop.
(defun grep-project (q)
"Search using git grep"
(interactive (list
(read-from-minibuffer "git grep: "
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(current-word))
nil nil 'grep-project)))
(let ((command
(concat
"cd " (magit-get-top-dir default-directory) " && "
"git grep --untracked -i -n --no-color --full-name '" q "' -- ")))
(add-to-history 'grep-find-history command)
(grep command)
))
(setenv "PAGER" "cat")
(global-set-key [(f3)] 'grep-project)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment