From a26b7a8116556349ee3a53fc329fcf73e5655dff Mon Sep 17 00:00:00 2001 From: jao Date: Fri, 18 Mar 2022 21:32:19 +0000 Subject: jao-shell: a couple functions moved there --- lib/eos/jao-shell.el | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'lib/eos') diff --git a/lib/eos/jao-shell.el b/lib/eos/jao-shell.el index f3ce438..ff1c160 100644 --- a/lib/eos/jao-shell.el +++ b/lib/eos/jao-shell.el @@ -24,14 +24,37 @@ ;;; Code: +(defun jao-shell--quote (x) (shell-quote-argument (format "%s" x))) + +;;;###autoload (defun jao-shell-cmd-lines (cmd &rest args) - (let ((cmd (concat cmd " " - (mapconcat #'shell-quote-argument args " ")))) + (let ((cmd (concat cmd " " (mapconcat #'jao-shell--quote args " ")))) (split-string (shell-command-to-string cmd) "\n" t))) - -(defun jao-shell-cmd-line (cmd &rest args) - (car (apply #'jao-shell-cmd-lines cmd args))) +;;;###autoload +(defun jao-shell-string (cmd &rest args) + (string-trim (or (car (apply #'jao-shell-cmd-lines cmd args)) ""))) + +;;;###autoload +(defun jao-shell-exec (command) + (interactive + (list (read-shell-command "$ " + (if current-prefix-arg + (cons (concat " " (buffer-file-name)) 0) + "")))) + (start-process-shell-command command nil command)) + +(defmacro jao-shell-def-exec (name &rest args) + `(defun ,name (&rest other-args) + (interactive) + (start-process-shell-command + ,(car args) + "*jao-exec - console*" + (string-join (append (list ,@args) other-args) " ")))) + +;;;###autoload +(defun jao-shell-running-p (pr) + (not (string-blank-p (shell-command-to-string (concat "pidof " pr))))) (provide 'jao-shell) ;;; jao-shell.el ends here -- cgit v1.2.3