The command
emacs -nw foo -f org-mode
opens the file foo in emacs in org-mode.
Now, suppose that the filename foo is the output of a script. How could I pipe to my command?
So, I'm trying to get something like
echo foo | emacs -nw {GET OUTPUT HERE} -f org-mode
to work. Is this possible?
EDIT: This question has been voted to close, but the answer referenced doesn't work and wasn't tested by the user who voted to close.
echo foo | xargs -I {} emacs -nw {} -f org-mode, or as alnx suggested,emacs -nw "$(echo foo)" -f org-mode. – muru Jul 11 '19 at 07:05echo foo | xargs -I {} emacs -nw {} -f org-modereturns an error for me. Does it work on your machine? – Brian Fitzpatrick Jul 11 '19 at 07:41emacs: standard input is not a tty– Brian Fitzpatrick Jul 11 '19 at 08:02emacswas run with the input as argument. You problem is that emacs doesn't like working in a pipeline, which means the idea behind your entire question is broken. Use a better editor – muru Jul 11 '19 at 08:08echo foo | xargs -I {} emacs -nw {} -f org-modeand now you're saying that my question is broken. The existence of an answer and my question being "broken" are mutually exclusive. – Brian Fitzpatrick Jul 11 '19 at 08:13xargsmethod there works in this aspect: the output of the command is used as an argument andemacsis started with that argument. In as much as this is your question, the method works - you can use stdout in the middle of a command. Try, say,echoorcatorvim, and you'll see the effect. The error you're getting is this: Afteremacshas been started with that argument, it sees that the input is a pipe, and it breaks. So the problem in the question has been solved, and now you have a new problem, which breaks your overall idea. Is that clearer? – muru Jul 11 '19 at 08:31emacsbehaves differently than the other commands. Why? This is totally not obvious. – Brian Fitzpatrick Jul 11 '19 at 08:33echo foo | xargs -I{} emacs -t /dev/tty -nw {} -f org-modeappears to work (no idea if there are other implications though) – steeldriver Jul 11 '19 at 11:10EDITOR=emacsclient....in various ways, see the link. – meuh Jul 11 '19 at 15:26