diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2025-10-31 17:22:00 +0100 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2025-10-31 17:22:00 +0100 |
| commit | 99433f640aa628e3f5ada562edbd5b61fe062448 (patch) | |
| tree | 8fe01ad889d6c69c0167ff62e8b03b7183b2fe75 | |
| parent | 85151064513f4dcb1674e637d45e01da147057a7 (diff) | |
Magit and Devbox
I typically develop in isolated developer containers/vms; this changes
the standard `C-x g` binding that opens the Magit status to instead
try and open the local git repository for a TRAMP remote file. This
makes it so I do Git things locally (including signing git commits)
but can still develop in an isolated `devbox` environment, without
having to share my GPG or SSH credentials.
| -rw-r--r-- | config/emacs/init.el | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/config/emacs/init.el b/config/emacs/init.el index add3676..1d183ac 100644 --- a/config/emacs/init.el +++ b/config/emacs/init.el @@ -75,6 +75,18 @@ (when is-dir (project-remember-projects-under name))))) +(defun devbox/magit-status () + "Opens the local Git status for a devbox directory. + +If the current buffer is not open in the devbox, then this function just runs +`magit-status' normally." + (interactive) + (if (equal (file-remote-p default-directory 'host) "devbox") + (let ((local-dir (tramp-file-name-localname + (tramp-dissect-file-name default-directory)))) + (magit-status-setup-buffer local-dir)) + (magit-status))) + ;;; -- Emacs Configuration -- (use-package emacs @@ -184,7 +196,7 @@ (use-package magit :ensure t - :bind (("C-x g" . magit-status))) + :bind (("C-x g" . devbox/magit-status))) (use-package undo-tree :ensure t @@ -205,8 +217,8 @@ (when (init/dev) (use-package copilot :ensure t - :bind (("C-<tab>" . copilot-accept-completion) - ("C-M-<tab>" . copilot-accept-completion-by-word) + :bind (("M-<tab>" . copilot-accept-completion) + ("C-<tab>" . copilot-accept-completion-by-word) ("C-c a a" . copilot-mode) ("C-c a n" . copilot-next-completion) ("C-c a p" . copilot-previous-completion)))) |
