1

Here is my current custom, but I don't know how to customize its face. And it only shows branch name, no other status info.

(setq-default
 mode-line-format
 (quote
  ((:eval
    (if vc-mode
        (progn
          (list
           (propertize " ⭠"
                       'face '(:foreground "sky blue"))
           ;; TODO: propertize this. set face height to 75
           `(vc-mode vc-mode)
           ))))
   )))

I hope someone can give out a better solution. Or at least tell me how to custom my upper status (vc-mode vc-mode) face.

1
  • Can you further suggest how to display the current branch in the dired modeline? May 12, 2017 at 18:20

1 Answer 1

5

In git, if you hover the mouse over the mode line portion which starts "Git", you get more information such as the branch and update status.

Looks like you've asked about mode line customization before here and here, so you should understand how to set values in the mode line.

To get the status of the file, the function you want is:

(vc-state (buffer-file-name (current-buffer)))

And to get the branch:

(vc-working-revision (buffer-file-name (current-buffer)))
5
  • 2
    For me (vc-working-revision (buffer-file-name (current-buffer))) return a hash number instead of a branch name like "master"
    – user27072
    Mar 23, 2020 at 11:57
  • @run_the_race - ok. Basically the command git rev-parse HEAD is run. GNU Emacs is open source, feel free to suggest changes to it, or post another solution. The particular file is to changer is git.savannah.gnu.org/cgit/emacs.git/tree/lisp/vc/vc-git.el#n349
    – rocky
    Mar 24, 2020 at 13:32
  • @rocky What about show git's branch name in mode line on Dired mode? Sep 29, 2021 at 12:01
  • @a_subscriber haven't a clue. Maybe you should post that as its own question if you are looking for an answer.
    – rocky
    Sep 30, 2021 at 13:43
  • @rocky I found. This help github.com/10sr/git-ps1-mode-el Sep 30, 2021 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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