【发布时间】:2017-10-08 14:01:04
【问题描述】:
我想向 comint shell-mode 发送命令,而不打印额外的提示。我正在尝试使用comint-redirect-* API,但我仍然收到额外的提示。有什么简单的方法可以完全避免提示打印,或者回溯并删除它?
我的重定向,
(defun my-comint-redirect-silently (proc string)
(let (comint-redirect-perform-sanity-check)
(with-temp-buffer
;; possible to have shell not print prompt?
(comint-redirect-send-command-to-process
string (current-buffer) proc nil 'no-display)))
(with-current-buffer (process-buffer proc)
;; necessary to track back and delete here?
(comint-redirect-cleanup)))
shell-hook 中的调用示例,
(add-hook 'shell-mode-hook
(lambda ()
(my-comint-redirect-silently
(get-buffer-process (current-buffer)) "TERM=xterm-256color")))
但是,comint shell 会打印以下内容(注意双重提示)
me@me-M51AC: ~
$ me@me-M51AC: ~
$
不直接相关,但是为了显示打印两次,这里的提示设置为
$ echo $PS1
${debian_chroot:+($debian_chroot)}\[\e[32m\]\u@\h: \[\e[33m\]\w\[\e[0m\]\n\$
【问题讨论】:
-
旁注:如果我
edebugmy-comint-redirect-silently并启动一个shell,提示只会打印一次 -
我认为您对
comint-send-string、comint-send-input之类的东西感兴趣....有关高级内容,另请参阅process-send-string。 -
@lawlist 不是真的,我试图暂时重定向输出,因此是“静默”。我已经有一个通用的劣质进程重定向库,类似于
ess的静默重定向,但我宁愿使用 new(?) comint 一个。 -
err 不是新的,我在 git log 中看到提到它可以追溯到 1999 年
标签: shell emacs comint-mode