这是一个运行 shell 脚本的简单 defun:
(defun bk-konsoles ()
"Calls: bk-konsoles.bash"
(interactive)
(shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ")
(if (buffer-file-name)
(file-name-directory (buffer-file-name)))
" &")
nil nil))
如果我启动一个没有 & 符号的程序 - 它会启动脚本,但会阻止 emacs 直到我关闭程序,如果我不放 & 符号它会给出错误:
/home/boris/its/plts/goodies/bk-konsoles.bash /home/boris/scl/geekgeek/: exited abnormally with code 1.
编辑:
所以现在我正在使用:
(defun bk-konsoles ()
"Calls: bk-konsoles.bash"
(interactive)
(shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ")
(if (buffer-file-name)
(file-name-directory (buffer-file-name)))
" & disown")
nil nil)
(kill-buffer "*Shell Command Output*"))
编辑 2:
不 - 不起作用:
(defun bk-konsoles ()
"Calls: bk-konsoles.bash"
(interactive)
(let ((curDir default-directory))
;; (shell-command (concat "nohup " (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ") curDir) nil nil)
(shell-command (concat (expand-file-name "~/its/plts/goodies/bk-konsoles.bash ")
curDir "& disown") nil nil)
(kill-buffer "*Shell Command Output*")))
让 emacs 保持忙碌 - 使用disown
, 或nohup
.
如果可能有帮助,这是我正在运行的脚本:bk-konsoles.bash