0

I simply want to execute the whole file I am editing right now in a small shell buffer just like I can run my python script. How can I do this?

  • What have you tried so far? – Dan Jun 18 '19 at 13:07
  • 2
    What about Execute script... and Execute region in the Sh-script menu? – Tobias Jun 18 '19 at 13:10
  • 1
    Thanks! Did not know that there is a major mode menu! Maybe I should activate the menu-bar that got deactivated in spacemacs sometimes – Tillus Jun 18 '19 at 13:21
  • 2
    Yes, the menus are there to make features more discoverable! I would not recommend disabling it. – phils Jun 19 '19 at 11:08
  • what is the emacs command associated to this ? – Welgriv Jul 28 '20 at 11:02
0

Here you can find a function that will send current line to the shell buffer: https://stackoverflow.com/questions/6286579/emacs-shell-mode-how-to-send-region-to-shell/7053298#7053298

Here is an adapted version that uses comint-scroll-to-bottom-on-output, so the shell buffer always scrolls to the last output: https://nistara.net/post/emacs-send-line-or-region-to-shell/

  • Hi. I havn't used Emacs in a while (spent too much time configuring). But if someone can confirm this solution I wil accept it. – Tillus Nov 27 '20 at 16:18
0

A possible workaround would be to select the entire buffer (C-x h) and then use the function to run a shell command on a region as explained on https://stackoverflow.com/questions/1871970/emacs-execute-code-in-shell-script-mode.

If I have a split window with the shell script on top and a session in bash below, it would indeed be nice to have a command to send the content of the upper buffer to the bash session and see the output without having to change to the buffer below.

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.