Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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))))))
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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