From 119fda8cc0e0bddcf33cbc25ad3af16dcb2498c1 Mon Sep 17 00:00:00 2001 From: David Morgan Date: Wed, 17 May 2023 12:56:42 +0100 Subject: [PATCH] Add my/magit-stage-and-commit-file --- .emacs.d/lisp/init-git.el | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.emacs.d/lisp/init-git.el b/.emacs.d/lisp/init-git.el index 0773a4e..e1f8d68 100644 --- a/.emacs.d/lisp/init-git.el +++ b/.emacs.d/lisp/init-git.el @@ -74,6 +74,7 @@ ("C-c g u" . my/magit-set-upstream) ("C-c g r" . my/magit-refresh-state) ("C-c g m" . my/magit-update-master) + ("C-c g C-c" . my/magit-stage-and-commit-file) :config ;; Requires the following gitconfig: ;; [alias] @@ -112,6 +113,12 @@ (magit-shell-command-topdir command))) (message "Not a git repository"))) + (defun my/magit-stage-and-commit-file () + "Stage and commit the current the currently visited file." + (interactive) + (magit-stage-file (magit-file-relative-name)) + (magit-commit-create)) + ;; difftastic code copied from https://tsdh.org/posts/2022-08-01-difftastic-diffing-with-magit.html (defun my/magit--with-difftastic (buffer command) "Run COMMAND with GIT_EXTERNAL_DIFF=difft then show result in BUFFER."