下面是一个简单defun定义运行shell脚本:如何在后台执行shell命令?
(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
提示:使用'async-shell-command'代替 – kindahero
@kindahero - 'async-shell-command'只是在场景后面添加&符号。如果这有效,那么他发布的内容也会起作用。 – Inaimathi
你可以像这样使用'disown':'your-command&diswon'。 – Daimrod