]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
add dired git
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sun, 22 Dec 2024 12:55:13 +0000 (13:55 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sun, 22 Dec 2024 12:55:13 +0000 (13:55 +0100)
* bba.org: dired-vc-rename-file git-add-files dired-git-add-marked-files

Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
bba.org

diff --git a/bba.org b/bba.org
index b5283144cb8c2376ee5665fb510cb300bd509fce..0492347e5c6678fff16330a388c200f40f17637a 100644 (file)
--- a/bba.org
+++ b/bba.org
@@ -2922,6 +2922,32 @@ Had to diff files on 2 different servers. What's better then dired and TRAMP?
 
 #+END_SRC
 
+* dired git
+[2024-05-28 Tue 11:35]
+
+#+begin_src emacs-lisp
+  (setq dired-vc-rename-file  t)
+
+  (defun git-add-files(files)
+  "Run git add with the input FILES."
+    (interactive)
+    (shell-command (format "git add %s" files)))
+
+  (defun dired-git-add-marked-files()
+  "For each marked file in a DIRED buffer add it to the index."
+    (interactive)
+    (if (eq major-mode 'dired-mode)
+        (let ((filenames (dired-get-marked-files))
+              (files ""))
+          (dolist (fn filenames)
+            (setq fn (shell-quote-argument fn))
+            (setq files (concat files " " fn)))
+          (git-add-files files))
+      (error (format "Not a Dired buffer \(%s\)" major-mode))))
+
+#+end_src
+
+
 * Get keychain password
 [2016-10-21 Fri 13:31]