* how to send lines of a shell script directly to the shell
@ 2023-04-16 8:53 Uwe Brauer
2023-04-16 9:05 ` tomas
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Uwe Brauer @ 2023-04-16 8:53 UTC (permalink / raw)
To: help-gnu-emacs
Hi
I have to execute a series of commands like
git checkout strings
mygit-push-named-branch strings
etc
It is a list of these commands in a file. I can call
M-x shell
And then copy each line to the shell where it is executed.
Is there any faster way, a command like
execute this line via the shell.
I googled but cannot find anything.
Regards
Uwe Brauer
--
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 8:53 how to send lines of a shell script directly to the shell Uwe Brauer
@ 2023-04-16 9:05 ` tomas
2023-04-16 10:03 ` Uwe Brauer
2023-04-16 10:09 ` Uwe Brauer
2023-04-16 15:31 ` Eduardo Ochs
2023-04-22 19:49 ` parozusa
2 siblings, 2 replies; 11+ messages in thread
From: tomas @ 2023-04-16 9:05 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 712 bytes --]
On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
>
>
> Hi
>
> I have to execute a series of commands like
>
> git checkout strings
> mygit-push-named-branch strings
> etc
>
> It is a list of these commands in a file. I can call
> M-x shell
>
> And then copy each line to the shell where it is executed.
>
> Is there any faster way, a command like
> execute this line via the shell.
>
> I googled but cannot find anything.
Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
c-h a (apropos) shell suggests shell-command-on-region, usually
bound to M-|
(of course, you'd have to mark the line; automating that is left
as an...)
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 9:05 ` tomas
@ 2023-04-16 10:03 ` Uwe Brauer
2023-04-16 12:57 ` tomas
2023-04-16 10:09 ` Uwe Brauer
1 sibling, 1 reply; 11+ messages in thread
From: Uwe Brauer @ 2023-04-16 10:03 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]
> On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
> Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
> c-h a (apropos) shell suggests shell-command-on-region, usually
> bound to M-|
> (of course, you'd have to mark the line; automating that is left
> as an...)
I tried this command out, before asking 😉
but this does not work, I mark the region
Run it and the mini-buffer asks:
shell-command-on-region
And you have to specify the command.
So that is thought that you run a already defined command on some
region.
But this is not what I want.
I want to send a certain line to the shell so that it is executed.
> Cheers
--
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 9:05 ` tomas
2023-04-16 10:03 ` Uwe Brauer
@ 2023-04-16 10:09 ` Uwe Brauer
2023-04-18 18:52 ` Leo Butler
1 sibling, 1 reply; 11+ messages in thread
From: Uwe Brauer @ 2023-04-16 10:09 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 823 bytes --]
> On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
> Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
With a bit better search I obtained
https://stackoverflow.com/questions/6286579/emacs-shell-mode-how-to-send-region-to-shell
Which does what I want
> c-h a (apropos) shell suggests shell-command-on-region, usually
> bound to M-|
> (of course, you'd have to mark the line; automating that is left
> as an...)
> Cheers
--
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 10:03 ` Uwe Brauer
@ 2023-04-16 12:57 ` tomas
0 siblings, 0 replies; 11+ messages in thread
From: tomas @ 2023-04-16 12:57 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 785 bytes --]
On Sun, Apr 16, 2023 at 12:03:41PM +0200, Uwe Brauer wrote:
>
> > On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
>
> > Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
>
> > c-h a (apropos) shell suggests shell-command-on-region, usually
> > bound to M-|
>
> > (of course, you'd have to mark the line; automating that is left
> > as an...)
>
> I tried this command out, before asking 😉
> but this does not work, I mark the region
>
> Run it and the mini-buffer asks:
>
> shell-command-on-region
>
> And you have to specify the command.
Oh, sorry, it was the other way around. We could, of course,
weasel our way out by specifyng /bin/sh or /bin/bash in the
minibuffer, but that's not what I meant ;-)
Cheers
--
t
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 8:53 how to send lines of a shell script directly to the shell Uwe Brauer
2023-04-16 9:05 ` tomas
@ 2023-04-16 15:31 ` Eduardo Ochs
2023-04-16 19:47 ` Uwe Brauer
2023-04-22 19:49 ` parozusa
2 siblings, 1 reply; 11+ messages in thread
From: Eduardo Ochs @ 2023-04-16 15:31 UTC (permalink / raw)
To: help-gnu-emacs
On Sun, 16 Apr 2023 at 05:54, Uwe Brauer <oub@mat.ucm.es> wrote:
>
> Hi
>
> I have to execute a series of commands like
>
> git checkout strings
> mygit-push-named-branch strings
> etc
>
> It is a list of these commands in a file. I can call
> M-x shell
>
> And then copy each line to the shell where it is executed.
>
> Is there any faster way, a command like
> execute this line via the shell.
>
> I googled but cannot find anything.
>
> Regards
>
> Uwe Brauer
Hi Uwe,
take a look at this too:
http://anggtwu.net/eepitch.html
http://anggtwu.net/eepitch.html#trying-it
http://anggtwu.net/emacsconf2021.html
The instructions at the "Trying it" are very simple and there's a very
nice demo in the first 30 seconds of my presentation at the
EmacsConf2021. The easiest way to watch it with subtitles is here,
http://www.youtube.com/watch?v=qM0Luz78qGw
and the easiest way to create the 3-line block that sets up the target
buffer is explained here:
http://anggtwu.net/eev-intros/find-eev-quick-intro.html#6.3
Cheers =),
Eduardo Ochs
http://anggtwu.net/#eev
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 15:31 ` Eduardo Ochs
@ 2023-04-16 19:47 ` Uwe Brauer
0 siblings, 0 replies; 11+ messages in thread
From: Uwe Brauer @ 2023-04-16 19:47 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 281 bytes --]
> On Sun, 16 Apr 2023 at 05:54, Uwe Brauer <oub@mat.ucm.es> wrote:
Hi Eduardo
> Hi Uwe,
> take a look at this too:
> http://anggtwu.net/eepitch.html
> http://anggtwu.net/eepitch.html#trying-it
> http://anggtwu.net/emacsconf2021.html
Thanks I will have a look, later.
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 10:09 ` Uwe Brauer
@ 2023-04-18 18:52 ` Leo Butler
2023-04-18 19:14 ` Emanuel Berg
2023-04-20 20:12 ` Uwe Brauer
0 siblings, 2 replies; 11+ messages in thread
From: Leo Butler @ 2023-04-18 18:52 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
On Sun, Apr 16 2023, Uwe Brauer <oub@mat.ucm.es> wrote:
>> On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
>
>> Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
>
> With a bit better search I obtained
>
> https://stackoverflow.com/questions/6286579/emacs-shell-mode-how-to-send-region-to-shell
>
> Which does what I want
There are several solutions there, you don't mention which you chose.
Anyhow, I recommend keyboard macros. That is generally much faster than
any alternative...if I find myself using a keyboard macro repeatedly,
then I will invest time in finding or writing a better alternative.
Alternatively, org-mode can do pretty much what you want.
Leo
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-18 18:52 ` Leo Butler
@ 2023-04-18 19:14 ` Emanuel Berg
2023-04-20 20:12 ` Uwe Brauer
1 sibling, 0 replies; 11+ messages in thread
From: Emanuel Berg @ 2023-04-18 19:14 UTC (permalink / raw)
To: help-gnu-emacs
Leo Butler wrote:
> Anyhow, I recommend keyboard macros. That is generally much
> faster than any alternative
They are?
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-18 18:52 ` Leo Butler
2023-04-18 19:14 ` Emanuel Berg
@ 2023-04-20 20:12 ` Uwe Brauer
1 sibling, 0 replies; 11+ messages in thread
From: Uwe Brauer @ 2023-04-20 20:12 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2070 bytes --]
>>> "LB" == Leo Butler <Leo.Butler@umanitoba.ca> writes:
> On Sun, Apr 16 2023, Uwe Brauer <oub@mat.ucm.es> wrote:
>>> On Sun, Apr 16, 2023 at 10:53:54AM +0200, Uwe Brauer wrote:
>>
>>> Ask your Emacs, not Google. Emacs is your friend, Google isn't :)
>>
>> With a bit better search I obtained
>>
>> https://stackoverflow.com/questions/6286579/emacs-shell-mode-how-to-send-region-to-shell
>>
>> Which does what I want
> There are several solutions there, you don't mention which you chose.
This one
(defun sh-send-line-or-region (&optional step)
(interactive ())
(let ((proc (get-process "shell"))
pbuf min max command)
(unless proc
(let ((currbuff (current-buffer)))
(shell)
(switch-to-buffer currbuff)
(setq proc (get-process "shell"))
))
(setq pbuff (process-buffer proc))
(if (use-region-p)
(setq min (region-beginning)
max (region-end))
(setq min (point-at-bol)
max (point-at-eol)))
(setq command (concat (buffer-substring min max) "\n"))
(with-current-buffer pbuff
(goto-char (process-mark proc))
(insert command)
(move-marker (process-mark proc) (point))
) ;;pop-to-buffer does not work with save-current-buffer -- bug?
(process-send-string proc command)
(display-buffer (process-buffer proc) t)
(when step
(goto-char max)
(next-line))
))
> Anyhow, I recommend keyboard macros. That is generally much faster than
> any alternative...if I find myself using a keyboard macro repeatedly,
> then I will invest time in finding or writing a better alternative.
Uff, I found this cumbersome
--
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military.
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine.
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/
[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: how to send lines of a shell script directly to the shell
2023-04-16 8:53 how to send lines of a shell script directly to the shell Uwe Brauer
2023-04-16 9:05 ` tomas
2023-04-16 15:31 ` Eduardo Ochs
@ 2023-04-22 19:49 ` parozusa
2 siblings, 0 replies; 11+ messages in thread
From: parozusa @ 2023-04-22 19:49 UTC (permalink / raw)
To: help-gnu-emacs
Uwe Brauer writes:
> Hi
>
> I have to execute a series of commands like
>
> git checkout strings
> mygit-push-named-branch strings
> etc
>
> It is a list of these commands in a file. I can call
> M-x shell
>
> And then copy each line to the shell where it is executed.
>
> Is there any faster way, a command like
> execute this line via the shell.
>
> I googled but cannot find anything.
>
> Regards
>
> Uwe Brauer
"list of commands in a file" = "shell script"
Make <file> executable by
$ chmod a+x <file>
and execute it
$ ./<file>
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2023-04-22 19:49 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-16 8:53 how to send lines of a shell script directly to the shell Uwe Brauer
2023-04-16 9:05 ` tomas
2023-04-16 10:03 ` Uwe Brauer
2023-04-16 12:57 ` tomas
2023-04-16 10:09 ` Uwe Brauer
2023-04-18 18:52 ` Leo Butler
2023-04-18 19:14 ` Emanuel Berg
2023-04-20 20:12 ` Uwe Brauer
2023-04-16 15:31 ` Eduardo Ochs
2023-04-16 19:47 ` Uwe Brauer
2023-04-22 19:49 ` parozusa
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.