HttpRepl icon indicating copy to clipboard operation
HttpRepl copied to clipboard

[Mac OS] Cannot set up default editor

Open igdmitrov opened this issue 5 years ago • 10 comments

Dear friends, I have a problem with settings the default editor on my Mac OS.

Terminal: code -w It works

HttpRepl: pref set editor.command.default "code" Doesn't work: The specified default editor path, "code", does not exist.

I tried another option: "/Applications/Visual Studio Code.app" It doesn't work too.

Thank you in advance!

igdmitrov avatar Dec 30 '20 19:12 igdmitrov

@f978gDDfsa You'll definitely need to specify the full path, not just code. Unfortunately, I can't really help you with what the full path is on your system (I also don't have a mac, so I'm not positive how to direct you to find it). Perhaps @bradygaster or someone else with Mac OS knowledge can chime in with that bit.

tlmii avatar Dec 30 '20 23:12 tlmii

I tried using this:

pref set editor.command.default "/Applications/Visual\ Studio\ Code.app

But when I try to execute it I end up getting the error:

The specified default editor path, "/Applications/Visual\ Studio\ Code.app", does not exist.

So I think it may require setting up an alias, which is somewhat annoying. If I come up with any other solution I'll definitely post it here. Wonder if @shirhatti might have any ideas.

bradygaster avatar Jan 04 '21 19:01 bradygaster

@bradygaster I'm not sure an alias will work - we do a File.Exists(...) check on the value (that's what's causing the error you see) and I'm guessing an alias will not actually exist.

Your editor path looks weird (why the \ ? Those will be literal \ characters in your path, it won't escape the space). Does it not work without those either?

tlmii avatar Jan 04 '21 19:01 tlmii

Good catch, @tlmii - that was copypasta error on my part. I spent a little time tweaking my settings and ended up with this, which works:

pref set editor.command.default.arguments "-w"
pref set editor.command.default "/Applications/Visual Studio Code.app/Contents/MacOS/Electron"

Adding @scottaddie here, in case he'd like to add this to the doc or if he thinks this is too much of an edge case for it to be included. Either way, it was sort of tricky to find the exact combination. These two together work like a champ. I can do a post and it pops open with the appropriate JSON payload ready-to-go.

bradygaster avatar Jan 04 '21 19:01 bradygaster

@bradygaster What about pref set editor.command.default "/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code"? That's what the docs already say (I probably should have checked that first... I just assumed the /Applications/Visual Studio Code.app path was what the docs said...)

tlmii avatar Jan 04 '21 19:01 tlmii

I should have as well. #facepalm. :) I'll validate what @scottaddie already has in the docs works as well as if not better than what I already have tested here. Then i'll shake the vacation cobwebs out of my hair and get back on the tricycle. :)

bradygaster avatar Jan 04 '21 19:01 bradygaster

I digress slightly from the original issue but I would've expected setting environment variables $EDITOR/$VISUAL to work as is the case of a lot of CLI tools, e.g., https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

If I didn't read the docs, the first thing I would have tried is $EDITOR="code -w" (which is already set in my bash profile) to just work.

shirhatti avatar Jan 04 '21 19:01 shirhatti

@shirhatti I went ahead and made a separate issue for that. We should be able to support the environment variables idea.

tlmii avatar Jan 04 '21 22:01 tlmii

I was also able to get this to work with /usr/local/bin/code, which is less authoritative than the Visual Studio Code.app/... path, but much easier to type.

jimmylewis avatar Jan 07 '21 06:01 jimmylewis