 (require 'dired-aux)
 (require 'seq)
 
-(defvar dwim-shell--execs nil "All execs in progress")
+(defvar dwim-shell--commands nil "All commands in progress")
 
 (cl-defstruct
-    dwim-shell--exec
-  "Describes an exec in progress."
+    dwim-shell--command
+  "Describes a command in progress."
   script
   process
   name

                                proc
                                progress-reporter
                                on-completion))
      (setq dwim-shell--execs
            (push (cons (process-name proc)
                        (make-dwim-shell--exec :script script
                                               :process proc
                                               :name (process-name proc)
                                               :calling-buffer (current-buffer)
                                               :files-before files-before
                                               :reporter progress-reporter))
                  dwim-shell--execs))
      (set-process-sentinel proc #'dwim-shell--sentinel)
      (set-process-filter proc #'dwim-shell--filter))))


    (if (y-or-n-p (format "Couldn't run %s, see output? " (buffer-name (process-buffer process))))
        (switch-to-buffer (process-buffer process))
      (kill-buffer (process-buffer process))))
  (setq dwim-shell--commands
        (map-delete dwim-shell--commands (process-name process))))

(defun dwim-shell--sentinel (process state)
  (let ((exec (map-elt dwim-shell--commands (process-name process))))
    (dwim-shell--finalize (dwim-shell--command-calling-buffer exec)
                          (dwim-shell--command-files-before exec)
                          process
                          (dwim-shell--command-reporter exec)
                          (dwim-shell--command-on-completion exec))))

(defun dwim-shell--filter (process string)
  (when-let* ((exec (map-elt dwim-shell--commands (process-name process)))
              (reporter (dwim-shell--command-reporter exec)))
    (progress-reporter-update reporter))
  (comint-output-filter process string))

