branch: externals/shell-command+
commit 51f90fd4ab4b352966a0d0a103262f7190973520
Author: Philip Kaludercic <[email protected]>
Commit: Philip Kaludercic <[email protected]>

    Add substitutions for Git commands with VC
---
 shell-command+.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/shell-command+.el b/shell-command+.el
index b9b1ad2fed..483eb194a2 100644
--- a/shell-command+.el
+++ b/shell-command+.el
@@ -284,6 +284,20 @@ prefix the command with \"../../../../\" or \"....\".")
   (pcase-let ((`(,_ ,directory) (shell-command+-tokenize command)))
     (cd directory)))
 
+(defun shell-command+-cmd-git (command)
+  "Convert COMMAND into a `git' call."
+  (pcase (shell-command+-tokenize command)
+    (`(,_ "log") (vc-print-log))
+    (`(,_ "log" ,ref) (vc-print-log ref))
+    (`(,_ "push") (vc-push))
+    (`(,_ "pull") (vc-update))
+    (`(,_ "fetch") (vc-log-incoming))
+    (`(,_ "merge") (vc-merge))
+    (`(,_ "diff") (vc-diff))
+    (`(,_ "switch" ,branch)
+     (vc-switch-branch default-directory branch))
+    (_ (async-shell-command command))))
+
 (defcustom shell-command+-clear-function
   (lambda ()
     (when-let* ((win (get-buffer-window)))
@@ -311,6 +325,7 @@ prefix the command with \"../../../../\" or \"....\".")
     ("make" . compile)
     ("sudo" . shell-command+-cmd-sudo)
     ("cd" . shell-command+-cmd-cd)
+    ("git" . shell-command+-cmd-git)
     ("clear" . shell-command+-cmd-clear))
   "Association of command substitutes in Elisp.
 Each entry has the form (COMMAND . FUNC), where FUNC is passed

Reply via email to