add gitswitch and git repo list to consult-buffer, do: g SPC

This commit is contained in:
2026-07-30 23:59:55 +02:00
parent 586caeffba
commit f94826d8cc
4 changed files with 58 additions and 11 deletions

View File

@@ -138,9 +138,9 @@
:custom-face
(blamer-face ((t :foreground "#7a88cf"
:background nil
:height 140
:italic t)))
:background nil
:height 140
:italic t)))
:config
(defalias 'blame 'blamer-mode)
@@ -148,10 +148,10 @@
;; in addition to blaming I also like to follow the lead, so make
;; the hash lead to the commit by clicking on it.
(defun blamer-callback-show-commit-diff (commit-info)
(interactive)
(let ((commit-hash (plist-get commit-info :commit-hash)))
(when commit-hash
(magit-show-commit commit-hash))))
(interactive)
(let ((commit-hash (plist-get commit-info :commit-hash)))
(when commit-hash
(magit-show-commit commit-hash))))
(setq blamer-bindings '(("<mouse-1>" . blamer-callback-show-commit-diff))))
@@ -161,5 +161,34 @@
(use-package sqlite3
:defer nil)
;; git helpers
(defun tvd-list-git-repos()
"Returns a list of all available git repositories in dev and fits/git"
(interactive)
(setq repos (list))
(let ((bases (list "~/dev" "~/fits/git")))
(dolist (base bases)
(dolist (dir (directory-files base nil "^[^\\.]"))
(if (and (file-accessible-directory-p (concat base "/" dir "/.git"))
(not (s-suffix? "bak" dir) ))
(push dir repos)))))
repos)
(defun tvd-switch-to-repo(repo)
"calls magit-status with <repo>, switches to and changes dir to it"
(interactive)
(let* ((devdir (concat "~/dev/" repo))
(fitsdir (concat "~/fits/git/" repo)))
(cond
((file-accessible-directory-p (concat devdir "/.git"))
(magit-status devdir))
((file-accessible-directory-p (concat fitsdir "/.git"))
(magit-status fitsdir)))))
(defun gitswitch()
"select a git repo from a list and switch to it"
(interactive)
(tvd-switch-to-repo (completing-read "select git repo> " (tvd-list-git-repos))))
(provide 'init-magit)
;;; init-magit.el ends here