tags:

views:

136

answers:

3

Hi all,

In sh-mode in Emacs, I was looking for a way to execute a shell script in the current buffer directly like the C-c C-c in Python-mode. Using M-! is really tiring. Any amount of googling doesn't help. Is this possible?

Please help.

Thanks

+1  A: 

Rebind M-! to something you like better, you can do it to the local keymap to just affect the shell buffer.

Don
+4  A: 

M-| is shell-command-on-region

so if you want to execute the whole buffer, C-x h M-| or you can rebind to something more convenient.

cobbal
Thanks Cobbol. M-| is cool!
Sahasranaman MS
+2  A: 

When I am editing a shell script called foo.sh, I set the variable compile-command to "foo.sh". Then, C-c m (compile) or C-c r (recompile) executes the script. C-c m lets me add or modify arguments to the script before running it, C-c r will run it with the last arguments used.

Neil