Magit split screen

A couple of months ago I started using Magit. Magit is a great interface for Git in Emacs, which lets you work efficiently and with great control. I'm not going to explain how Magit works in this post, so if you're interested in learning more about Magit, take a look at the Magit repository and this great introduction by the Mastering Emacs blog.

The magit split screen comes alive

I was really impressed with Magit and started to use it as my main tool for working with Git. However, I quickly found a few things I needed to improve to make it perfect for my environment. One of those were to have an easy way for opening Magit for several repositories in split screen.

So I put together a simple function that opens Magit for the three repositories I needed in a split screen:

(defun magit-split () 
    (magit-status "~/path/to/first/repo") 
    (magit-status "~/path/to/second") 
    (magit-status "~/path/to/third") 

This function does the following:

  1. Execute magit-status command for the path that is given as an argument.
  2. Repeat step 1 with another repo as an argument.
  3. Split the window horizontally.
  4. Execute magit-status for the last repo.
  5. Balance the windows, so they have the same width.

The function will result in following screen:

As with all my Emacs commands, I've created a shortcut for the magit-split:

(global-set-key (kbd "C-x C-g") 'magit-split)

So there you have it. My Magit split screen command.