`open` command
mgutz opened this issue · comments
Mario Gutierrez commented
You asked about cross-platform open command, these are the aliases I use in my dotfiles
Windows: start
Linux (ubuntu, debian): xdg-open
OSX: open
Oscar N. commented
There is also a package that takes care of this - https://github.com/jjrdn/node-open
Alexey Shamrin commented
node-open approximately does the following:
opener = {darwin: "open", win32: "start"}[process.platform] ? "xdg-open"
exec "#{opener} http://localhost:1234"
There's a complication: for some reason node-open bundles vendor/xdg-open shell script.
(What does xdg-open
do? It detects the desktop environment and calls into gvfs-open
, gnome-open
, kde-open
etc.)
To stop worrying about whether xdg-open
exists or not, you could use Python webbrowser module instead:
opener = {darwin: "open", win32: "start"}[process.platform] ? "python -m webbrowser -t"
exec "#{opener} http://localhost:1234"
Jeremy Ashkenas commented
I fudged the commit message, but this should be fixed now.