Control open -f temporary file name

When I use echo 'hello world' | open -f it creates a temporary file in /tmp folder with some arbitrary name.

Is there any way for me to set the name and the path I want for open -f temporary file?


What technically happens here is the following:

  • f tells open to read input from standard input and open the results in the default text editor
  • Because most text editors can't read the content to be edited from standard input, open creates a temporary file with the input it receives from standard input and then opens the default text editor on this file.
  • According to man open there is no option to set a custom name for that file

As a workaround you can use

echo 'hello world' > /tmp/foo.txt && open /tmp/foo.txt

which technically does exactly the same thing.