Function: actypes::exec-shell-cmd
actypes::exec-shell-cmd is an interactive and byte-compiled function
defined in hactypes.el.
Signature
(actypes::exec-shell-cmd SHELL-CMD &optional INTERNAL-CMD KILL-PREV)
Documentation
Execute a SHELL-CMD string asynchronously.
Optional non-nil second argument INTERNAL-CMD inhibits display of the shell command line executed. Optional non-nil third argument KILL-PREV means kill the last output to the shell buffer before executing SHELL-CMD.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/hyperbole-20260414.325/hactypes.el
;;; Support next two actypes on systems which use the `comint' shell package.
(defact exec-shell-cmd (shell-cmd &optional internal-cmd kill-prev)
"Execute a SHELL-CMD string asynchronously.
Optional non-nil second argument INTERNAL-CMD inhibits display of the shell
command line executed. Optional non-nil third argument KILL-PREV means
kill the last output to the shell buffer before executing SHELL-CMD."
(interactive
(let ((default (nth 0 hargs:defaults))
(default1 (nth 1 hargs:defaults))
(default2 (nth 2 hargs:defaults)))
(list (hargs:read "Shell cmd: "
(lambda (cmd) (not (string-equal cmd "")))
default "Enter a shell command." 'string)
(y-or-n-p (format "Omit cmd from output (default = %s)? "
default1))
(y-or-n-p (format "Kill prior cmd's output (default = %s)? "
default2)))))
(require 'comint)
(let ((buf-name "*Hyperbole Shell*")
(obuf (current-buffer))
(default-dir (expand-file-name default-directory)))
(unwind-protect
(progn
(unless (hpath:remote-p default-dir)
(setq shell-cmd
(concat "cd " default-dir " && " shell-cmd)))
(if (and (get-buffer buf-name)
(get-buffer-process (get-buffer buf-name)))
(hpath:display-buffer buf-name)
;; (hpath:display-buffer (current-buffer))
(when (eq (minibuffer-window) (selected-window))
(other-window 1))
;; 'shell' calls pop-to-buffer which normally displays in
;; another window
(setq buf-name (buffer-name (shell buf-name))))
(while (not (and (buffer-live-p (get-buffer buf-name))
(buffer-modified-p (get-buffer buf-name))))
;; Wait for shell to startup before sending it input.
(sit-for 1))
(setq comint-last-input-start (point-marker)
comint-last-input-end (point-marker)))
(goto-char (point-max))
(and kill-prev comint-last-input-end
(not (equal comint-last-input-start comint-last-input-end))
(comint-delete-output))
(insert shell-cmd)
(comint-send-input)
(comint-show-output)
(or internal-cmd (scroll-down 1)))
(select-window (or (get-buffer-window obuf t) (selected-window)))))