maxheld83 / byod

make life easier with r projects and docker
MIT License
0 stars 0 forks source link

automatically open browser window to correct url #10

Open maxheld83 opened 5 years ago

maxheld83 commented 5 years ago

this would be nice to have. @Ch1pzZz suggested to do this by locating the browser exe, but I don't think that scales (will be different on every OS and computer). It might be worthwhile to figure out whether there is a system utility to open the system default browser to a certain URL from the shell.

If there is no such system utility, it might be worthwhile installing one.

Or maybe some browsers have a CLI interface that we could call, and we could just use that if the browser is installed.

But overall, this isn't super important. We can also just point users to open a url in the browser.

Ch1pzZz commented 5 years ago

https://stackoverflow.com/questions/3124556/clean-way-to-launch-the-web-browser-from-shell-script

found this. Think this should open the brower and the URL could be entered in the script too. If it works the way I think it does that should also make #11 obsolete as we could use the line in the scrip and people wouldnt even have to copy the URL?

maxheld83 commented 5 years ago

I think it should be possible to hack together a little wrapper using the commands in this so-answer. You'd basically be checking in some order whether some tool is available, and if not, test the next one until the script can successfully open the browser, or exit with a warning message or something. It's not super critical to open the browser, so it need not be an error if it's not possible.

I guess on macos you'd have to use the call in one of the other answers open....

So as not to paste macOS commands into Linux and vice-versa, it might be a good idea to test whether the current OS is Linux or macOS, independently of which tools are available. open ... AFAIK, doesn't exist/work on Linux, so it'd be weird to even test it there.

But those are just details, I think this answer has all of whats needed.

Basically a lot of bash control flow (if clauses :).