I use the following code to run "ls -l ./" and get the result in scratch buffer.
(start-process "my-process" "*scratch*" "ls" "-l" "./")
You can adjust this to your liking:
(kill-new (shell-command-to-string "ls -l ."))
The call to kill-new
will put the string from shell-command-to-string
on the kill ring.
shell-command
(bound to M-!) runs a shell command and puts its output in *Shell Command Output*
. Given an argument (eg: M-1 M-!) it will put the results in the current buffer.
A little more information is available on the page ExecuteExternalCommand on the Emacs wiki
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With