I am using Magit to work with git in emacs. I have bound magit-status to a key, but every time I hit the key it opens in a split in lower half of the window and i have to hit C-x 1 to get it into a full window. How can I make it open in a full window by default?
8 Answers
(setq magit-status-buffer-switch-function 'switch-to-buffer)
or via customize:
M-x customize-variable RET magit-status-buffer-switch-function RET
- 
                    17Note that with current Magit, new buffer behavior is handled by `magit-display-buffer-function`. – Mathieu Marques Mar 16 '16 at 10:42
 - 
                    1That changes the command to `M-x` `customize-variable` `RET` `magit-display-buffer-function` `RET`. – young_souvlaki Mar 21 '21 at 15:26
 
For newer versions of Magit you can use this sanctioned snippet:
(setq magit-display-buffer-function #'magit-display-buffer-fullframe-status-v1)
I combine it with this to get a zen-like full window Git status after switching projects:
(setq projectile-switch-project-action 'magit-status)
- 31,030
 - 13
 - 103
 - 118
 
- 1,225
 - 10
 - 13
 
- 
                    4That's actually the full frame, for full window, it's magit-display-buffer-same-window-except-diff-v1. – ergosys Dec 18 '18 at 23:04
 - 
                    3
 - 
                    
 
Here is another way to achieve this:
(add-to-list 'same-window-regexps "\*magit: .*\*")
- 81
 - 1
 - 2
 
This solution has the advantage that you can kill the fullscreen buffer in quit-window style:
(defadvice magit-status (around magit-fullscreen activate)
  (window-configuration-to-register :magit-fullscreen)
  ad-do-it
  (delete-other-windows))
(defadvice magit-mode-quit-window (after magit-restore-screen activate)
  "Restores the previous window configuration and kills the magit buffer"
  (jump-to-register :magit-fullscreen))
(define-key magit-status-mode-map (kbd "q") 'magit-mode-quit-window)
If you have an older version of magit then you might need to rename magit-mode-quit-window to magit-quit-window.
- 1,624
 - 14
 - 22
 
Note! Newer versions of magit use the function, magit-display-buffer-function, and this can be harnessed to get the same behaviour. The following snippet will give you the desired, fullscreen, magit bounty.
(defun display-buffer-full-screen (buffer alist)
  (delete-other-windows)
  (set-window-dedicated-p nil nil)
  (set-window-buffer nil buffer)
  (get-buffer-window buffer))
(setq magit-display-buffer-function
      (lambda (buffer)
        (if magit-display-buffer-noselect
            (magit-display-buffer-traditional buffer)
          (display-buffer buffer '(display-buffer-full-screen)))))
- 1,624
 - 14
 - 22
 
I use this:
(defun my-magit-status ()
  "Don't split window."
  (interactive)
  (let ((pop-up-windows nil))
    (call-interactively 'magit-status)))
- 8,336
 - 12
 - 54
 - 94
 
- 17,079
 - 4
 - 51
 - 49
 
Another option is to customize the variable display-buffer-alist.
If all you want is magit, you can do this:
(customize-set-variable
     'display-buffer-alist
     '(("\\*magit: .*" display-buffer-same-window)))
- 3,229
 - 3
 - 17
 - 37
 
- 
                    Nice, but for recent versions of magit you need to remove the leading asterisk in the condition: `"magit: .*"` – tmalsburg Mar 20 '23 at 09:47
 
For Magit v2.90.1, the correct answer didn't suit me. With the line below it achieved the best results.
(setq magit-display-buffer-function 'magit-display-buffer-same-window-except-diff-v1)
Other display functions can be found by the prefix magit-display-buffer-.
- 2,766
 - 23
 - 28