I want that when I choose a project from the list presented by projectile-switch-project, projectile changes the current working directory to the chosen project's root directory.

I tried this:

;; cd into dir i want, including git-root
  (defun cd-dwim ()
      (cd (projectile-project-root)))
  (setq projectile-switch-project-action 'cd-dwim)

Did not work. It projectile-project-root does not receive the new path from the project I just chose.

I'd love if I was able to write something like this:

(setq projectile-switch-project-action 

Is it possible?

  • When you say 'changes the current working directory', what do you want to do with it? open it with dired? cd changes the current buffer's working directory.
    – omajid
    Commented Nov 18, 2016 at 20:45
  • I just want that after I invoke projectile-switch-project and chose a project, a later invocation of M-x projectile-find-file will search files inside the root directory of the project I just chose.
    – ninrod
    Commented Nov 18, 2016 at 21:25
  • @ninrod It should work as you described without any config. Commented Nov 18, 2016 at 23:38
  • @displayname actually without any config, after choosing a project, projectile immediately forces me to chose a file from all the files in the project. If I don't choose a file, then projectile does not switch to the project that I want.
    – ninrod
    Commented Nov 19, 2016 at 0:56
  • @ninrod Sorry I misunderstood your needs. I don't know that you even don't want to open a file in project. You should set it to projectile-dired. Or just use the default binding C-c p D. Commented Nov 19, 2016 at 3:33

1 Answer 1


The default action is projectile-find-file. Change it to projectile-dired, and whenever you switch project, you get into a dired buffer of the root of that project:

(setq projectile-switch-project-action 'projectile-dired)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.