Start file searchs from basic sh/dash shell

Uses the most basic, uncustomized shell to a) prevent interference
caused by slow shell configs and b) speed up project text searches. This
comes at the cost of isolating these programs from envvars that the user
may have set in their shell configs in order to change
ag/rg/pt/git-grep/grep's behavior.

If this bothers you, change +ivy-file-search-shell to your shell (or
to the value of `shell-file-name`).

Possibly relevant to an issue mentioned in #1260
This commit is contained in:
Henrik Lissner 2019-06-17 15:01:00 +02:00
parent 855ff34e2c
commit 0a7221798b
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -307,6 +307,20 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
(#'counsel-file-jump)))) (#'counsel-file-jump))))
(defvar +ivy-file-search-shell
(or (executable-find "dash")
(executable-find "sh")
shell-file-name)
"The SHELL to invoke ag/rg/pt/git-grep/grep searchs from.
This only affects `+ivy/*' search commands (e.g. `+ivy/rg' and
`+ivy/project-search').
By default, this the most basic, uncustomized shell, to prevent interference
caused by slow shell configs at the cost of isolating these programs from
envvars that may have been set in the user's shell config to change their
behavior. If this bothers you, change this to `shell-file-name'.")
;;;###autoload ;;;###autoload
(cl-defun +ivy-file-search (engine &key query in all-files (recursive t)) (cl-defun +ivy-file-search (engine &key query in all-files (recursive t))
"Conduct a file search using ENGINE, which can be any of: rg, ag, pt, and "Conduct a file search using ENGINE, which can be any of: rg, ag, pt, and
@ -359,7 +373,8 @@ order.
((file-relative-name directory project-root)))))) ((file-relative-name directory project-root))))))
(require 'counsel) (require 'counsel)
(let ((ivy-more-chars-alist (let ((ivy-more-chars-alist
(if query '((t . 1)) ivy-more-chars-alist))) (if query '((t . 1)) ivy-more-chars-alist))
(shell-file-name +ivy-file-search-shell))
(pcase engine (pcase engine
(`grep (`grep
(let ((counsel-projectile-grep-initial-input query)) (let ((counsel-projectile-grep-initial-input query))