diff options
author | jao <jao@gnu.org> | 2022-03-18 21:32:19 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-03-18 21:32:19 +0000 |
commit | a26b7a8116556349ee3a53fc329fcf73e5655dff (patch) | |
tree | 70f996ec8464dd1ead910a669f3049d4aaacd0c7 /lib/eos | |
parent | 24823ba43c3b1cbc7330d1aa2f140154f98987b0 (diff) | |
download | elibs-a26b7a8116556349ee3a53fc329fcf73e5655dff.tar.gz elibs-a26b7a8116556349ee3a53fc329fcf73e5655dff.tar.bz2 |
jao-shell: a couple functions moved there
Diffstat (limited to 'lib/eos')
-rw-r--r-- | lib/eos/jao-shell.el | 33 |
1 files changed, 28 insertions, 5 deletions
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 |