Last active
September 27, 2015 08:27
-
-
Save zkat/1240784 to your computer and use it in GitHub Desktop.
git-grep in emacs
This file contains 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 git-grep (regexp) | |
(interactive "sSearch in git repo: ") | |
(grep (format "GIT_PAGER='' git grep -nH --no-color -i \"%s\" -- $(git rev-parse --show-toplevel)" regexp))) | |
(global-set-key (kbd "C-x ?") 'git-grep) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, the irony
(defun git-grep (command-args)
(interactive
(let ((root (vc-git-root default-directory)))
(when (not root)
(setq root git-grep-default-work-tree)
(message "git-grep: %s doesn't look like a git working tree; searching from %s instead" defa
ult-directory root))
(list (read-shell-command "Run git-grep (like this): "
(format (concat
"cd %s && "
"git grep %s -e %s")
root
git-grep-switches
(let ((thing (and