Skip to content

Instantly share code, notes, and snippets.

@knollet
Last active May 11, 2023 08:59
Show Gist options
  • Save knollet/cb11657d3ecdf894973bd1c3ff7bce23 to your computer and use it in GitHub Desktop.
Save knollet/cb11657d3ecdf894973bd1c3ff7bce23 to your computer and use it in GitHub Desktop.
(defun term-git-mode--get-branch ()
(let ((branches (vc-call-backend 'git 'branches)))
(when branches (car branches))))
(define-minor-mode term-git-mode
"show current branch in modeline in terminal-modes"
:lighter (:eval (let ((git-branch (term-git-mode--get-branch)))
(if git-branch
(format " git:%s" git-branch)
""))))
(add-hook 'term-mode-hook 'term-git-mode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment