Function: treemacs-run-shell-command-in-project-root
treemacs-run-shell-command-in-project-root is an interactive and
byte-compiled function defined in treemacs-interface.el.
Signature
(treemacs-run-shell-command-in-project-root &optional ARG)
Documentation
Run an asynchronous shell command in the root of the current project.
Output will only be saved and displayed if prefix ARG is non-nil.
Every instance of the string $path will be replaced with the (properly quoted)
absolute path of the project root.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/treemacs-20251226.1307/treemacs-interface.el
(defun treemacs-run-shell-command-in-project-root (&optional arg)
"Run an asynchronous shell command in the root of the current project.
Output will only be saved and displayed if prefix ARG is non-nil.
Every instance of the string `$path' will be replaced with the (properly quoted)
absolute path of the project root."
(interactive "P")
(let* ((cmd (read-shell-command "Command: "))
(name "*Treemacs Shell Command*")
(node (treemacs-node-at-point))
(buffer (progn (--when-let (get-buffer name)
(kill-buffer it))
(get-buffer-create name)))
(working-dir nil))
(treemacs-block
(treemacs-error-return-if (null node)
(treemacs-pulse-on-failure "There is no project here."))
(-let [project (treemacs-project-of-node node)]
(treemacs-error-return-if (treemacs-project->is-unreadable? project)
(treemacs-pulse-on-failure "Project path is not readable."))
(setf working-dir (treemacs-project->path project)
cmd (s-replace "$path" (shell-quote-argument working-dir) cmd))
(pfuture-callback `(,shell-file-name ,shell-command-switch ,cmd)
:name name
:buffer buffer
:directory working-dir
:on-success
(if arg
(progn
(pop-to-buffer pfuture-buffer)
(require 'ansi-color)
(ansi-color-apply-on-region (point-min) (point-max)))
(treemacs-log "Shell command completed successfully.")
(kill-buffer buffer))
:on-error
(progn
(treemacs-log-failure "Shell command failed with exit code %s and output:" (process-exit-status process))
(message "%s" (pfuture-callback-output))
(kill-buffer buffer)))))))