emacs:如何从dired do shell命令捕获标准输出?
在Emacs中,有没有办法捕获dired do shell命令的stdout,比如对kill ringemacs:如何从dired do shell命令捕获标准输出?,emacs,dired,Emacs,Dired,在Emacs中,有没有办法捕获dired do shell命令的stdout,比如对kill ring 在不知道如何操作的情况下,我最终转到消息缓冲区并从那里手动获取标准输出。该命令的帮助说明,如果命令没有&,则输出将转到名为*Shell command output*的缓冲区。如果是这种情况,这段代码将执行您想要的操作: (defun do-shell-and-copy-to-kill-ring (command &optional arg file-list) (interact
在不知道如何操作的情况下,我最终转到消息缓冲区并从那里手动获取标准输出。该命令的帮助说明,如果命令没有
&
,则输出将转到名为*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))))
对于异步命令,您需要等待它们并查看
*异步Shell命令*
缓冲区。谢谢!我用它将您的解决方案连接到我的设置中:(defun my dired mode keys()“Modify keymap by`dired mode.”(本地设置键(kbd“C-cd”)“do shell and copy to kill ring”)(添加hook'dired mode hook'我的dired mode keys)