newContentEditor trouble with spaces?

I’m using macOS 12.6 and Hugo v0.104.3 extended. My config file is written in YAML.

I’d like to use an editor with spaces in its name (iA Writer) for the newContentEditor config option. It appears the space isn’t escaped when running hugo new, resulting in the following error:

Content "/Users/luke/Developer/lukework/content/blog/2022/10/test/" created
Editing "/Users/luke/Developer/lukework/content/blog/2022/10/test/" 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/]: The file /Users/luke/Developer/lukework/Writer" does not exist.

Of note is the part where it seems to be looking for the file “Writer” in my project root.

I also tested it with Sublime Text and VS Code.

Things I’ve tried/checked:

  • open is whitelisted in the security config, I’ve been using it with Typora
  • Tried different escape techniques for the app name: backslash or single/double quotes
  • Tried single/double quotes around the entire command, e.g. newContentEditor: "open -a iA\ Writer"
  • Tried aliasing the open command + args to a shell alias + reloading shell config (both zsh and fish)
  • Tried the absolute path for each editor, e.g. /Applications/iA
  • Tried the --editor flag with hugo new

The open command works correctly in the terminal:

open -a "iA Writer" 
open -a "iA\ Writer"
open -a "Visual Studio Code"

Thanks in advance for any help on this. Let me know if you need more info.

Of course, as soon as I post this, I find a workaround. Using the bundle identifier with open works:

newContentEditor: open -b pro.writer.mac
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.