(defun async-shell-command (command &optional output-buffer error-buffer)
"Execute string COMMAND asynchronously in background.
Like `shell-command', but adds `&' at the end of COMMAND
to execute it asynchronously.
The output appears in the buffer whose name is stored in the
variable `shell-command-buffer-name-async'. That buffer is in
You can configure `async-shell-command-buffer' to specify what to do
when the buffer specified by `shell-command-buffer-name-async' is
already taken by another running shell command.
To run COMMAND without displaying the output in a window you can
configure `display-buffer-alist' to use the action
`display-buffer-no-window' for the buffer given by
In Elisp, you will often be better served by calling `start-process'
directly, since it offers more control and does not impose the use of
a shell (with its need to quote arguments)."
(read-shell-command (if shell-command-prompt-show-cwd
(format-message "Async shell command in `%s': "
"Async shell command: ")
((eq major-mode 'dired-mode)
(dired-get-filename nil t)))))
(and filename (file-relative-name filename))))
(unless (string-match "&[ \t]*\\'" command)
(setq command (concat command " &")))
(shell-command command output-buffer error-buffer))