I've written the following snippet which (as far as I can tell) does what you're looking for from the point of view of the ! command.
It does the following:
- Takes the files that would have operated on by dired-do-shell-command (i.e. the
! key). This will be either the marked files, the file under point if nothing is marked or the files specified by a prefix arg. As far as I can tell this is the same as the behavior you get from
- Downloads a local (temporary) copy of each of the files in directory specified by
temporary-file-directory on your system.
dired-do-shell-command in that directory on that file or files
(defun dired-do-local-command ()
(let* ((marked-files (dired-get-marked-files nil current-prefix-arg))
(local-tmp-files (mapcar #'file-local-copy marked-files))
(num-files (length local-tmp-files))
(command (dired-read-shell-command "! on %s: " num-files marked-files)))
(dired-do-shell-command command num-files local-tmp-files)))
You can bind this to a key in dired mode (I've chosen ") with
(define-key dired-mode-map (kbd "\"") 'dired-do-local-command)
and it should behave similarly to the ! key.