Projectile is pretty great, but I'm finding it difficult to have it turned on only in places where it would be effective.
As I understand it, the two standard choices are to turn it on manually, as in major mode hooks, or to enable it globally with projectile-global-mode
. I find the former not broad enough; I want to be able to access projectile commands while visting any file in a project, regardless of its type. But turning the mode on globally is too broad; it gets turned on even when visiting such manifestly non-project directories as my home directory, /tmp
, /etc
, etc.
Is there a standard way to activate projectile-mode
only when visiting a file that lives in an actual project, as might be determined by, say, checking for the existence of a .git
, .svn
, etc, directory in some ancestor directory of the current file?