emacs:如何从 dired-do-shell-command 捕获标准输出?
emacs: How to Capture stdout from dired-do-shell-command?
在 Emacs 中,有没有办法捕获 dired-do-shell-command 的标准输出,比如 kill-ring?
不知道怎么做,我最终转到 Messages 缓冲区并从那里手动获取标准输出。
该命令的帮助说明输出到名为 *Shell Command Output*
的缓冲区,假设命令没有 &
。如果是这种情况,这段代码将执行您想要的操作:
(defun do-shell-and-copy-to-kill-ring (command &optional arg file-list)
(interactive
(let ((files (dired-get-marked-files t current-prefix-arg)))
(list
(dired-read-shell-command "! on %s: " current-prefix-arg files)
current-prefix-arg
files)))
(dired-do-shell-command command arg file-list)
(with-current-buffer "*Shell Command Output*"
(copy-region-as-kill (point-min) (point-max))))
对于异步命令,您需要等待它们并在 *Async Shell Command*
缓冲区中查找。
在 Emacs 中,有没有办法捕获 dired-do-shell-command 的标准输出,比如 kill-ring?
不知道怎么做,我最终转到 Messages 缓冲区并从那里手动获取标准输出。
该命令的帮助说明输出到名为 *Shell Command Output*
的缓冲区,假设命令没有 &
。如果是这种情况,这段代码将执行您想要的操作:
(defun do-shell-and-copy-to-kill-ring (command &optional arg file-list)
(interactive
(let ((files (dired-get-marked-files t current-prefix-arg)))
(list
(dired-read-shell-command "! on %s: " current-prefix-arg files)
current-prefix-arg
files)))
(dired-do-shell-command command arg file-list)
(with-current-buffer "*Shell Command Output*"
(copy-region-as-kill (point-min) (point-max))))
对于异步命令,您需要等待它们并在 *Async Shell Command*
缓冲区中查找。