Create and Open New Post with One-Liner in Terminal

This should be easy, but my ‘Terminal-Fu’ is letting me down.

What I want is to create a new post in the terminal and then pass this file reference to the ‘mate’ command [TextMate’s command line invocation] with a one-liner.

When I try the usual unix pipe approach:

hugo new 2015-07-19-blah-blah.md | mate

TextMate opens with a new document containing the path to the Hugo post, rather than opening the post itself.

Can someone put me out of my misery?

Set your editor of choice in config.toml:

NewContentEditor = "mate"
1 Like

Thanks. I didn’t know about that option at all.

As chance would have it, I stumbled upon the answer to my question about a nano-second after posting it here –in spite of previously having searched in vain for ages.

hugo new 1015-07-19-blah-blah.md | xargs mate

is the magic formula.

You can also do
hugo --editor=mate new to get the same result.

I mistakenly put editor=vim in my config file and was confused by why it didn’t work but now it’s working correctly with newContentEditor=vim and it’s great.