From a2e0b173323a5b20b6bf3965d9f2f8c055c0ad06 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Thu, 5 May 2022 14:21:40 -0400 Subject: [PATCH] Add run-command recipe for project script files --- emacs/.emacs.d/config/init-run-command.el | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/emacs/.emacs.d/config/init-run-command.el b/emacs/.emacs.d/config/init-run-command.el index a9d3d0c..06e6653 100644 --- a/emacs/.emacs.d/config/init-run-command.el +++ b/emacs/.emacs.d/config/init-run-command.el @@ -330,6 +330,24 @@ :working-dir rake-dir)) cmds))) + (defvar run-command-recipe-scripts--script-dirs '("." "bin" "scripts")) + + (defun run-command-recipe-scripts () + (let* ((root-dir (expand-file-name (or (projectile-project-root) default-directory))) + (shell (or (getenv "SHELL") "/usr/bin/env bash")) + (scripts (-mapcat + (lambda (dir) + (let ((dir (f-join root-dir dir))) + (when (f-dir? dir) + (f-files dir #'file-executable-p)))) + run-command-recipe-scripts--script-dirs))) + (-map + (lambda (file) + (list :command-name (f-relative file root-dir) + :command-line file + :working-dir root-dir)) + scripts))) + :general (leader-map "\"" #'run-command) :custom @@ -350,6 +368,7 @@ run-command-recipe-pip run-command-recipe-maven run-command-recipe-cargo - run-command-recipe-rake))) + run-command-recipe-rake + run-command-recipe-scripts))) (provide 'init-run-command)