Created
October 29, 2014 21:10
-
-
Save til/fe24eebae7bcf799b08f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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