From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: Redirecting the output of a commend in "shell" into a buffer
Date: Wed, 03 Sep 2014 19:49:45 +0200 [thread overview]
Message-ID: <87d2bcd26e.fsf@debian.uxu> (raw)
In-Reply-To: mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org
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
next prev parent reply other threads:[~2014-09-03 17:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.8181.1409733682.1147.help-gnu-emacs@gnu.org>
2014-09-03 16:35 ` Redirecting the output of a commend in "shell" into a buffer Emanuel Berg
2014-09-03 17:49 ` Emanuel Berg [this message]
2014-09-03 8:40 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87d2bcd26e.fsf@debian.uxu \
--to=embe8573@student.uu.se \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.