From 415ace37251a4423c28a5261dea4bfccd6cfc620 Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sun, 23 Jun 2024 21:21:50 +0200 Subject: [PATCH] feat: init run-command, shell-command-x --- init.el | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index c00d942..b26a217 100644 --- a/init.el +++ b/init.el @@ -808,7 +808,7 @@ :config (global-anzu-mode +1)) -;; Vterm +;; Shell (my-use-package vterm :ensure t :commands vterm @@ -834,6 +834,41 @@ "t t" '(vterm-toggle :wk "Toggle terminal") "t T" '(vterm :wk "Open terminal"))) +(my-use-package shell-command-x + :ensure t + :config + (shell-command-x-mode 1)) + +(my-use-package run-command + :ensure t + :general + (my-leader + "r" '(run-command :wk "Run command")) + :custom + (run-command-recipes '( + run-command-recipe-watchexec + run-command-recipe-make + )) + :init + (defun run-command-recipe-watchexec () + "Ask for a command and run it whenever the current file is saved. + + Requires `watchexec' (https://watchexec.github.io/) to be installed." + (when-let ((buffer-file (buffer-file-name))) + (list + (list + :display + (format "Run arbitrary command whenever `%s' is saved" + (file-name-nondirectory buffer-file)) + :command-name "watchexec" + :command-line + (lambda () + (let ((command-to-run + (shell-quote-argument (read-string "Enter command: ")))) + (format "watchexec --clear --watch '%s' '%s'" + buffer-file + command-to-run)))))))) + ;; MMM mode ;; (my-use-package mmm-mode ;; :ensure t -- 2.48.1