How to open magit-status in full window
Asked Answered
C

8

32

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?

Coal answered 24/2, 2012 at 23:49 Comment(0)
C
31
(setq magit-status-buffer-switch-function 'switch-to-buffer)

or via customize:

M-x customize-variable RET magit-status-buffer-switch-function RET

Crossroads answered 25/2, 2012 at 2:25 Comment(2)
Note that with current Magit, new buffer behavior is handled by magit-display-buffer-function.Jimmy
That changes the command to M-x customize-variable RET magit-display-buffer-function RET.Exegetic
B
24

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)

Barden answered 4/10, 2018 at 5:50 Comment(3)
That's actually the full frame, for full window, it's magit-display-buffer-same-window-except-diff-v1.Immitigable
Thanks for adding the neat projectile addition!Millenary
Anyway to keep the same buffers open upon exit?Outlay
R
8

Here is another way to achieve this:

(add-to-list 'same-window-regexps "\*magit: .*\*")

Rosannarosanne answered 30/7, 2014 at 0:58 Comment(0)
I
4

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.

Inferior answered 20/2, 2014 at 16:24 Comment(0)
G
3

I use this:

(defun my-magit-status ()
  "Don't split window."
  (interactive)
  (let ((pop-up-windows nil))
    (call-interactively 'magit-status)))
Gorky answered 25/2, 2012 at 1:21 Comment(0)
I
3

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)))))
Inferior answered 13/4, 2016 at 15:57 Comment(0)
H
2

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-.

Havens answered 25/10, 2019 at 7:53 Comment(0)
N
1

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)))
Needham answered 2/2, 2017 at 20:58 Comment(1)
Nice, but for recent versions of magit you need to remove the leading asterisk in the condition: "magit: .*"Mythopoeic

© 2022 - 2024 — McMap. All rights reserved.