Is there a way to jump straight to the magit-status page of another git project?

233 Views Asked by At

My general workflow for going to another project is

  1. projectile-switch-project which pops up a helm interface for picking a project
  2. select a project
  3. select a file within the project to open the file
  4. then run magit-status

Is there a way to combine steps 2-4?

3

There are 3 best solutions below

4
On BEST ANSWER
  1. projectile-switch-project which pops up a helm interface for picking a project

If you want to use projectile with helm, you could give helm-projectile a try.

  1. helm-projectile-switch-project
  2. then choose your project with M-g or f3 instead of RET

enter image description here

0
On

If I understand your question correctly, you may be able to code a little function that does what you need and attach it to projectile-after-switch-project-hook. At least running magit-status on that hook (if it's a git project), should be pretty easy to do.

EDIT: Tried it out. It interferes with projectile-switch-project-action. Good news is that you can just use that instead.

Here's a draft:

(defun my-projectile-switch-project-action ()
  (interactive)
  ;; test for some typical files in my projects
  (ignore-errors
    (let ((files '("README" "README.md" "build.gradle")))
      (while files
        (message "Looking for: %s" (first files))
        (if (file-exists-p (first files))
            (progn
              (find-file-other-window (first files))
              (setq files nil))
          (setq files (rest files))))))
  ;; now run magit
  (if (vc-git-responsible-p default-directory)
      (magit-status)))


;; Use the function like this:
(setq projectile-switch-project-action
      #'my-projectile-switch-project-action)

I hereby put above code under the GPLv2 or later in addition to StackOverflow's standard license. You can chose under which license you want to receive this code.

0
On

If you don't use many projectile features, you can take a look at the built-in project, whose project-switch-project will let you select a command after selecting the project like: enter image description here

Or you may add actions to open magit status for the project to helm like https://occasionallycogent.com/emacs_custom_helm_actions/index.html (something similar embark in helm if I remember correctly)