american-ninja-warrior
american-ninja-warrior

Reputation: 8235

emacs cd for all splits

In emacs you can do M-x cd to change the default directory.

I usually have 5 splits/windows, so the cd I do in the first split does't affect the others. What If I want the cd to affect all my splits/buffers. Is there an alternative command I can use?

Upvotes: 0

Views: 70

Answers (1)

Brian Malehorn
Brian Malehorn

Reputation: 2685

There's nothing built-in but it's not too hard to write the function by hand:

(defun cd-all-windows (dir)
  (interactive "Ddirectory: ")
  (dolist (window (window-list))
    (with-current-buffer (window-buffer window)
      (cd dir))))

Put that in your .emacs and you should be able to run M-x cd-all-windows to get the desired effect.

Upvotes: 4

Related Questions