* Redirecting the output of a commend in "shell" into a buffer
@ 2014-09-03 8:40 C K Kashyap
2014-09-03 20:22 ` Memnon Anon
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: C K Kashyap @ 2014-09-03 8:40 UTC (permalink / raw)
To: help-gnu-emacs@gnu.org
Hi,
While using shell, is it possible to redirect output of commands into a
buffer?
Ofcourse, the shell buffer itself is editable and all but it would be nice
if I could directly pipe the output of a command into a new buffer.
Regards,
Kashyap
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Redirecting the output of a commend in "shell" into a buffer
2014-09-03 8:40 Redirecting the output of a commend in "shell" into a buffer C K Kashyap
@ 2014-09-03 20:22 ` Memnon Anon
[not found] ` <mailman.8221.1409775768.1147.help-gnu-emacs@gnu.org>
2014-09-05 23:02 ` Robert Thorpe
2 siblings, 0 replies; 9+ messages in thread
From: Memnon Anon @ 2014-09-03 20:22 UTC (permalink / raw)
To: help-gnu-emacs
C K Kashyap <ckkashyap@gmail.com> writes:
> While using shell, is it possible to redirect output of commands into a
> buffer?
Try eshell:
>Welcome to the Emacs shell
>
>~ $ ls > #<buffer lsout>
>~ $
hth
--
/-------------------------------------------\
| SDF and SDF-EU Public Access UNIX System |
| http://sdf.org || http://sdf-eu.org |
=============================================
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.8221.1409775768.1147.help-gnu-emacs@gnu.org>]
* Re: Redirecting the output of a commend in "shell" into a buffer
[not found] ` <mailman.8221.1409775768.1147.help-gnu-emacs@gnu.org>
@ 2014-09-04 1:59 ` Rusi
2014-09-04 4:13 ` C K Kashyap
[not found] ` <mailman.8237.1409804019.1147.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 9+ messages in thread
From: Rusi @ 2014-09-04 1:59 UTC (permalink / raw)
To: help-gnu-emacs
On Thursday, September 4, 2014 1:52:05 AM UTC+5:30, Memnon Anon wrote:
> C K Kashyap writes:
> > While using shell, is it possible to redirect output of commands into a
> > buffer?
> Try eshell:
> >Welcome to the Emacs shell
> >~ $ ls > #<buffer lsout>
> >~ $
Neat! Where is this documented?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Redirecting the output of a commend in "shell" into a buffer
2014-09-04 1:59 ` Rusi
@ 2014-09-04 4:13 ` C K Kashyap
[not found] ` <mailman.8237.1409804019.1147.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 9+ messages in thread
From: C K Kashyap @ 2014-09-04 4:13 UTC (permalink / raw)
To: Rusi; +Cc: help-gnu-emacs@gnu.org
Thanks Memnon ... eshell does not seem to be an option for me. I am working
with visual studio projects that seem to work with shell and not eshell.
Regards,
Kashyap
On Thu, Sep 4, 2014 at 7:29 AM, Rusi <rustompmody@gmail.com> wrote:
> On Thursday, September 4, 2014 1:52:05 AM UTC+5:30, Memnon Anon wrote:
> > C K Kashyap writes:
>
> > > While using shell, is it possible to redirect output of commands into a
> > > buffer?
>
> > Try eshell:
>
> > >Welcome to the Emacs shell
> > >~ $ ls > #<buffer lsout>
> > >~ $
>
> Neat! Where is this documented?
>
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.8237.1409804019.1147.help-gnu-emacs@gnu.org>]
* Re: Redirecting the output of a commend in "shell" into a buffer
[not found] ` <mailman.8237.1409804019.1147.help-gnu-emacs@gnu.org>
@ 2014-09-04 18:48 ` Emanuel Berg
0 siblings, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2014-09-04 18:48 UTC (permalink / raw)
To: help-gnu-emacs
C K Kashyap <ckkashyap@gmail.com> writes:
> Thanks Memnon ... eshell does not seem to be an
> option for me. I am working with visual studio
> projects that seem to work with shell and not eshell.
I suspected that (well, not the exact shell) - but you
can still use eshell for this specific purpose. It is
not optimal but unless you do this all the time I think
it is a good option. Otherwise you will have to do some
combined shell/Emacs hacking unless someone else
already did.
--
underground experts united
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Redirecting the output of a commend in "shell" into a buffer
2014-09-03 8:40 Redirecting the output of a commend in "shell" into a buffer C K Kashyap
2014-09-03 20:22 ` Memnon Anon
[not found] ` <mailman.8221.1409775768.1147.help-gnu-emacs@gnu.org>
@ 2014-09-05 23:02 ` Robert Thorpe
2014-09-06 8:21 ` C K Kashyap
2 siblings, 1 reply; 9+ messages in thread
From: Robert Thorpe @ 2014-09-05 23:02 UTC (permalink / raw)
To: C K Kashyap; +Cc: help-gnu-emacs
C K Kashyap <ckkashyap@gmail.com> writes:
> Hi,
> While using shell, is it possible to redirect output of commands into a
> buffer?
> Ofcourse, the shell buffer itself is editable and all but it would be nice
> if I could directly pipe the output of a command into a new buffer.
Emanuel gave one solution, here's another.
There's a hook called "comint-filter-functions" and a command called
"comint-send-input". Together these control what gets sent to the
external process in things like shell buffers.
You could modify these or advice them. Or you could rebind RET. For
example, suppose you create a new "pseudo-command" called "buf". You
write: "buf ls RET" in the shell buffer. Your function finds the "buf"
at the beginning of the command string. It then cuts out the rest and
sends it to shell-command which puts it in a separate buffer. If it
doesn't find "buf" at the start then it calls comint-send-input as
usual.
I've thought about doing this myself but I've never got around to it.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Redirecting the output of a commend in "shell" into a buffer
2014-09-05 23:02 ` Robert Thorpe
@ 2014-09-06 8:21 ` C K Kashyap
0 siblings, 0 replies; 9+ messages in thread
From: C K Kashyap @ 2014-09-06 8:21 UTC (permalink / raw)
To: Robert Thorpe; +Cc: help-gnu-emacs@gnu.org
Robert - I love emacs more ... I am looking into how to
use comint-output-filter-functions - I have not figured it out yet but it
looks awesome!
Regards,
Kashyap
On Sat, Sep 6, 2014 at 4:32 AM, Robert Thorpe <rt@robertthorpeconsulting.com
> wrote:
> C K Kashyap <ckkashyap@gmail.com> writes:
>
> > Hi,
> > While using shell, is it possible to redirect output of commands into a
> > buffer?
> > Ofcourse, the shell buffer itself is editable and all but it would be
> nice
> > if I could directly pipe the output of a command into a new buffer.
>
> Emanuel gave one solution, here's another.
>
> There's a hook called "comint-filter-functions" and a command called
> "comint-send-input". Together these control what gets sent to the
> external process in things like shell buffers.
>
> You could modify these or advice them. Or you could rebind RET. For
> example, suppose you create a new "pseudo-command" called "buf". You
> write: "buf ls RET" in the shell buffer. Your function finds the "buf"
> at the beginning of the command string. It then cuts out the rest and
> sends it to shell-command which puts it in a separate buffer. If it
> doesn't find "buf" at the start then it calls comint-send-input as
> usual.
>
> I've thought about doing this myself but I've never got around to it.
>
> BR,
> Robert Thorpe
>
^ permalink raw reply [flat|nested] 9+ messages in thread
[parent not found: <mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org>]
* Re: Redirecting the output of a commend in "shell" into a buffer
[not found] <mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org>
@ 2014-09-03 16:35 ` Emanuel Berg
2014-09-03 17:49 ` Emanuel Berg
1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2014-09-03 16:35 UTC (permalink / raw)
To: help-gnu-emacs
C K Kashyap <ckkashyap@gmail.com> writes:
> Hi, While using shell, is it possible to redirect
> output of commands into a buffer? Ofcourse, the shell
> buffer itself is editable and all but it would be
> nice if I could directly pipe the output of a command
> into a new buffer. Regards, Kashyap
Are you using the Emacs shell (within Emacs) or some
other shell (bash, zsh) outside of Emacs?
If you are in Emacs all along what you want already
happens, and can be setup for specific purposes with
some creativity.
But I suspect you want this from outside of Emacs, in
what case a poor man's solution is redirecting the
output to a certain file; in Emacs, setup a keystroke
to open a buffer from that file. (That is fast, if you
have a shortcut to go from the shell to Emacs as well.)
Otherwise, for the full-power solution, you must use
IPC (perhaps a "named pipe" or FIFO) or Emacs as a
server:
https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html
I can't help you as I never did that, but if you get it
right, be sure to tell us how you did it!
Good luck!
--
underground experts united
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Redirecting the output of a commend in "shell" into a buffer
[not found] <mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org>
2014-09-03 16:35 ` Emanuel Berg
@ 2014-09-03 17:49 ` Emanuel Berg
1 sibling, 0 replies; 9+ messages in thread
From: Emanuel Berg @ 2014-09-03 17:49 UTC (permalink / raw)
To: help-gnu-emacs
C K Kashyap <ckkashyap@gmail.com> writes:
> Hi, While using shell, is it possible to redirect
> output of commands into a buffer? Ofcourse, the shell
> buffer itself is editable and all but it would be
> nice if I could directly pipe the output of a command
> into a new buffer.
I combined some of my old stuff into the poor-man's
solution I spoke of earlier. If you have two shortcuts
- one to go to Emacs from the shell - and one to invoke
`pipe-buffer' (in Emacs), it is not that poor.
I could actually go to Emacs at the end of pipe-out...
but that wouldn't be perfect either, because in Emacs,
one would still have to invoke `pipe-buffer'. So, I'll
leave it double imperfect requiring two strokes. But
the stroke to go to Emacs should already be there, and
be habitually used - and, sudden (unasked for) shifts
between applications are a pain.
To be non-IPC I like this solution!
The reason for `do-show-file' is so that it won't ask
if you want the new version each time.
In Emacs:
(defun do-show-file (file)
(interactive "f file")
(progn
(switch-to-buffer
(find-file-noselect file t)) ; nowarn
(revert-buffer t t nil) ; ignore-auto noconfirm preserve-modes
(message nil) ))
(defun pipe-buffer ()
(interactive)
(do-show-file "~/.emacs.d/piped-out.txt") )
In zsh:
#!/bin/zsh
pipe-out () {
pipe_file=~/.emacs.d/piped-out.txt
if (( $# )); then # usage: $ pipe-out `cmd`
input=$* # or: $ pipe-out `cmd1` plain `cmd2` (etc.)
else
read -d \\0 input # $ cmd | pipe-out
fi
echo $input >> $pipe_file
}
The code is here - fixes will be put there, as well:
http://user.it.uu.se/~embe8573/conf/emacs-init/files-my.el
http://user.it.uu.se/~embe8573/conf/emacs-init/linux-shell.el
http://user.it.uu.se/~embe8573/conf/.zsh/zsh-to-emacs
--
underground experts united
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2014-09-06 8:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-03 8:40 Redirecting the output of a commend in "shell" into a buffer C K Kashyap
2014-09-03 20:22 ` Memnon Anon
[not found] ` <mailman.8221.1409775768.1147.help-gnu-emacs@gnu.org>
2014-09-04 1:59 ` Rusi
2014-09-04 4:13 ` C K Kashyap
[not found] ` <mailman.8237.1409804019.1147.help-gnu-emacs@gnu.org>
2014-09-04 18:48 ` Emanuel Berg
2014-09-05 23:02 ` Robert Thorpe
2014-09-06 8:21 ` C K Kashyap
[not found] <mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org>
2014-09-03 16:35 ` Emanuel Berg
2014-09-03 17:49 ` Emanuel Berg
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.