Last active
December 31, 2015 22:09
-
-
Save bmnn/8051352 to your computer and use it in GitHub Desktop.
emacs; git; shell; grep; save; change buffers; capture shell output; cd; replace regexp;
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
setq last-search "") | |
(defun gg (searchstring) | |
"git-grep the entire current repo" | |
(cd (replace-regexp-in-string "\n" "" (shell-command-to-string "git rev-parse --show-toplevel"))) | |
(interactive (list (completing-read "Search for: " nil nil nil (concat | |
last-search " -e ")))) | |
(when buffer-file-name (save-buffer)) | |
(call-process "git" nil "*Messages*" nil "add" "- u") | |
(call-process "git" nil "*Messages*" nil "add" "\*.org") | |
(grep-find (concat "git grep -P -n -I -i --full-name --all-match " searchstring)) | |
(switch-to-buffer "*grep*") | |
(delete-other-windows) | |
(setq last-search searchstring) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment