I use the command locate --regex '/.git$' | grep username to get a list of all the Git repositories under my $HOME folder.
Is there a way to load them all into Projectile, to make them all instantly available?
I use the command locate --regex '/.git$' | grep username to get a list of all the Git repositories under my $HOME folder.
Is there a way to load them all into Projectile, to make them all instantly available?
You can add a single project to Projectile's runtime list of known projects (projectile-known-projects) using the command projectile-add-known-project, which interactively prompts you for the root directory of a project.
In order to add multiple projects at a time, you can use projectile-known-projects-file, which is read when projectile.el is first loaded. This file can either be modified by hand, or updated with the contents of projectile-known-projects using the command projectile-cleanup-known-projects. The contents of projectile-known-projects-file form a list of project root directories, e.g. ("~/src/emacs/" "~/src/projectile/").
ADDENDUM:
You could also write your own function which:
projectile-known-projects; andprojectile-known-projects to projectile-known-projects-file for persistence by calling (projectile-save-known-projects).EDIT (tip for Git and Magit users):
If you use Magit, you can reuse some of its git repository locating functionality (see magit-repos.el) in your Projectile configuration. Here's an example from my own configuration:
Configure magit-repository-directories (which see) to include the desired directories. Note that each entry can be associated with a subdirectory depth. If you organise all your projects as subdirectories of a select few parent directories, then only the parent directories need be added to magit-repository-directories, with the corresponding search depth. For example:
(with-eval-after-load 'magit
(setq magit-repository-directories
'(;; Directory containing project root directories
("~/src/" . 2)
;; Specific project root directory
("~/dotfiles/" . 1))))
After Projectile is loaded, you can add all repositories reported by Magit to projectile-known-projects using something like:
(with-eval-after-load 'projectile
(when (require 'magit nil t)
(mapc #'projectile-add-known-project
(mapcar #'file-name-as-directory (magit-list-repos)))
;; Optionally write to persistent `projectile-known-projects-file'
(projectile-save-known-projects)))
(If you use use-package you can replace with-eval-after-load 'projectile with use-package projectile :config.)