Created
July 18, 2012 03:00
-
-
Save suhailshergill/3133867 to your computer and use it in GitHub Desktop.
magit: buffer label
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun su/magit/format-magit-status-buffer-name () | |
"Append the value of current branch to `magit-status' buffer" | |
(let ((magit-status-buffer-name (buffer-name (magit-find-status-buffer))) | |
(branch-name (magit-get-current-branch)) | |
(buffer-name-regex "^\\(\\*.*\\*\\)\\(.*\\)?$")) | |
(dolist (buffer-name `(,magit-status-buffer-name ,magit-log-buffer-name)) | |
(string-match buffer-name-regex buffer-name) | |
(ignore-errors (with-current-buffer buffer-name | |
(rename-buffer (replace-match (concat "\\1" (format | |
" (%s)" | |
branch-name)) | |
nil nil buffer-name))))) | |
;; update `magit-log-buffer-name' | |
(string-match buffer-name-regex magit-log-buffer-name) | |
(setq magit-log-buffer-name (replace-match (concat "\\1" (format " (%s)" | |
branch-name)) | |
nil nil magit-log-buffer-name)) | |
)) | |
(add-hook 'magit-refresh-status-hook 'su/magit/format-magit-status-buffer-name) | |
;; move to a hook? ping sigma about it? | |
(eval-after-load 'magit | |
'(progn | |
(defadvice magit-refresh-log-buffer (after | |
su/advice/magit/magit-refresh-log-buffer/after/branch-name-annotation | |
a c pre) | |
"Tweak the `*magit-log*' buffer to also show the current branch | |
name. This really belongs in a hook, but since the hook for that doesn't exist, | |
and i can't be arsed to send a pull request for magit just go with an advice." | |
(su/magit/format-magit-status-buffer-name)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment