Using iA Writer with Hugo

No spaces.

I’m testing out iA Writer for editing Markdown. I’ve been using it on iOS to quickly edit my Obsidian vault, since the Obsidian iOS app has a lot of friction.

On macOS, I ran into an issue with Hugo, the SSG I use for this blog. Hugo’s newContentEditor config option can open a text editor after running the command for starting a new post, hugo new.

With Typora, I had it set up like this:

# config.yaml
newContentEditor: open -a Typora

Replacing Typora with iA Writer threw these errors:

Content "/Users/luke/Developer/lukework/content/blog/2022/10/test/index.md" created
Editing "/Users/luke/Developer/lukework/content/blog/2022/10/test/index.md" with "open" ...
The file /Users/luke/Developer/lukework/Writer" does not exist.
Error: failed to execute binary "
open" with args [-a "iA Writer" /Users/luke/Developer/lukework/content/blog/2022/10/test/index.md]: The file /Users/luke/Developer/lukework/Writer" does not exist.

Escaping the space in the name worked in the terminal, but didn’t work in Hugo:

open -a "iA Writer" foo.md 
open -a "iA\ Writer" foo.md
open -a "Visual Studio Code" foo.md

Looking at the manual for open, you can use the app’s bundle identifier with the -b flag instead. I grabbed iA Writer’s with this command:

codesign -dr - /Applications/iA\ Writer.app

And here’s what my Hugo config looks like now:

# config.yaml
newContentEditor: open -b pro.writer.mac