kendo-labs / kendo-bootstrapper

GNU General Public License v3.0
49 stars 20 forks source link

Recognize .app packages as code editors on Mac #24

Open toddanglin opened 11 years ago

toddanglin commented 11 years ago

When configuring the Bootstrapper to use a specific code editor via the Bootstrapper Options dialog, it currently does not recognize ".app" packages on a Mac as executables. Instead, it produces an error: "You selected a directory."

While it is true that Mac apps are in fact directories, it would be nice if the Bootstrapper could recognize these packages and properly configure the desired code editor. It would be a more intuitive configuration process than forcing users to locate the app's command file.

bsatrom commented 11 years ago

@mishoo perhaps one approach we could take would be to turn this dialog into a drop-down list of popular editors (with only OS-compatible editors shown) that the use can choose from and then perhaps show the dialog if they select an other/custom option. For 80%+ folks, the editors will be installed in "standard" locations, so it would save them some hunting and us some trouble if we just provide those.

mishoo commented 11 years ago

It would be nice if there was a standard way to locate apps, or to open apps on the Mac, and there probably is and I don't know it. The bootstrapper can run shell commands so if there was a way to figure out, say, what's the user's favorite app for editing .js files and how to run it it would be great.

/me considering buying a mac...

bsatrom commented 11 years ago

@mishoo I just poked around in a couple of IDEs I have on my machine, and it looks like the path is actually pretty standard, after all:

/Contents/MacOS/<Name of .app folder>

So there might be a simple solution, after all. If the dev selects the .app, we can just transform that selection to the path above.

mishoo commented 11 years ago

I just learned that there's an open command — http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/open.1.html — that would allow us to edit a file with the user's preferred app. Do you guys think that would be a good fall-back on OSX?

Edit: so the bootstrapper would just run i.e. open -t filename.js and let OSX decide which app to use. The downside is that I can't figure out how to pass args to open the file at a certain line/col (which we currently support in a painful way for the various editors that the bootstrapper "knows" by default).

bsatrom commented 11 years ago

oh sweet! So we can fall back to the OS to handle the preferred app to use, etc? If so, I think that's a great fallback. Would you only use that when an editor is not found or not defined?

toddanglin commented 11 years ago

I think that should be the default behavior. Less configuration is better!

Well…actually…as I think about it, I think some people might have things like Chrome or Safari configured as the default program for opening JS and HTML files. Maybe we should, in fact, try to detect code editors first and then fallback on the OS settings.

When we ask someone to pick their editor, do we have the ability to invoke the default OS "Choose Application" dialog?

bsatrom commented 11 years ago

If we used Brackets Shell, we could! :D :8ball: :facepunch:

mishoo commented 11 years ago

@toddanglin according to that man page, the -t flag will trigger opening the file with the default text editor. I hope that doesn't mean TextEdit though, but there's nowhere I can test. :( Any case, I'll implement that as fallback for when no known editor is found or configured.

@bsatrom I doubt that about Brackets Shell ;-) Unless we'd implement it in ObjectiveC and link it against Brackets. We could do that anyhow, as the Bootstrapper can run arbitrary commands—we could implement the app choser in C and ship the binary. But there has to be a better way..