Is there a way to show the current branch, pluses, minuses, and authors in emacs status bar? Something like:

-UU-:**--F1 buildfile Top (84,16) (Ruby Paredit AC yas Fill) ---(git: master +2/-4 Jake Pearson


I came up with this:

(defadvice vc-git-mode-line-string (after plus-minus (file) compile activate)
  (setq ad-return-value
    (concat ad-return-value
            (let ((plus-minus (vc-git--run-command-string
                               file "diff" "--numstat" "--")))
              (and plus-minus
                   (string-match "^\\([0-9]+\\)\t\\([0-9]+\\)\t" plus-minus)
                   (format " +%s-%s" (match-string 1 plus-minus) (match-string 2 plus-minus)))))))

which puts Git:master +9-2 in my mode line.

Not sure what you mean by author - would that be the author of the latest commit? If so, this seems to work:

(defadvice vc-git-mode-line-string (after author (file) compile activate)
  (setq ad-return-value
        (concat ad-return-value
                (let ((author
                       (vc-git--run-command-string file "log" "-n1" "--pretty=format:%an" "--")))
                  (when author
                    (concat " " author))))))
| improve this answer | |

Have you tried emacs-powerline?

| improve this answer | |
  • How will it help? Can you add a brief summary? – Rory Alsop May 18 '17 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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