0

=> When I do M-x shell-command and python run.py (which only print Hello World\nHello World string), I get the result on the minibuffer and when cursor moves up/down minibuffer is closed.

enter image description here

=> When I do M-x eshell-command and pwd I get the result on another window instead of the mini-buffer I had to do C-x-1 to close it. Please note that, if the output is single line it is printed in the minibuffer.

enter image description here

=> Can eshell-command direct its output like shell-command into minibuffer if the output is more than a single line?

2

It can't without modifying the code, but you can do it yourself

(defun your-eshell-command (command)
  "Execute eshell COMMAND and display output in the echo area."
  (interactive "sEshell command: ")
  (message "%s" (eshell-command-result command)))

shell-command's output behavior is smarter

If the output is short enough to display in the echo area (which is determined by the variables resize-mini-windows and max-mini-window-height), it is shown there

5
  • On native eshell-command tab works to do auto-completion, is it possible to achieve completion too in your-eshell-command func
    – alper
    Nov 10 '20 at 9:43
  • It also prints additional new line at the end is it possible to prevent it from printing? which is not printed on eshell-command
    – alper
    Nov 10 '20 at 9:47
  • @alper On completion, you need to copy-and-paste eshell-command's code, or use read-shell-command which is for shell not eshell, but might be good enough. On trailing new lines, you can use string-trim-right to remove them.
    – xuchunyang
    Nov 10 '20 at 10:20
  • Ok as I understand, instead of eshell-command-result I can use read-shell-command
    – alper
    Nov 10 '20 at 10:40
  • 1
    @alper nope, (interactive "sEshell command: ") is like read-string which does not provide completion, you use (interactive (list (read-shell-command "Eshell command: "))) to get completion.
    – xuchunyang
    Nov 10 '20 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.