Historical Perspective
On Unix like operating systems, it is common practice to redirect IO between shell commands using pipes.
For example, the command below would insert all the lines that didn't match "10.1.2.3" into the *scratch*
buffer in emacs.
`cat /tmp/ip-addresses.txt | grep -vi "10.1.2.3" | emacs --insert /path/to/stdin`
There are numerous ways to do this same task inside of emacs too. One of the easiest methods is probably something like the example below:
M-! cat /tmp/ip-addresses.txt | grep -vi "10.1.2.3"
The output from the command would be displayed in new buffer named *Shell Command Output*
One of my favorite features, is to run shell commands asynchronously inside of emacs.
M-& tail -f /tmp/ip-addresses.txt | grep -vi "10.1.2.3"
The output from the command would be displayed and be automagically refreshed in new buffer named *Async Shell Command*
.
Problem
Unfortunately, when I run the asynchronous command outside of emacs the *scratch*
buffer will never refresh when the file is updated by another process.
tail -f /tmp/ip-addresses.txt | grep -vi "10.1.2.3" | emacs --insert /path/to/stdin
Question
Is there some way to continue reading from a STDIN file descriptor when data is PIPED to Emacs on Command-line?
Note: I'm looking for an answer that shows how to continue reading the redirected IO from the PIPE by modifying the emacs command-line.
For example, to update the destination buffer from
*scratch*
to a buffer namedSTDIN
I would modify the original command-line like so:
cat /tmp/ip-addresses.txt | grep -vi "10.1.2.3" | emacs --eval "(set-buffer (generate-new-buffer \"STDIN\"))" --insert /path/to/stdin
Thanks for your help!
GNU Emacs 24.5.1 (x86_64-unknown-cygwin, GTK+ Version 3.14.13)