Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A 'b url' command or similar to open a URL in the browser the terminal is accessed through. #184

Open
GrahamDumpleton opened this issue Jan 12, 2019 · 2 comments

Comments

@GrahamDumpleton
Copy link
Contributor

Is it technically possible to implement a b url command that could communicate over the web socket back to the browser that the terminal is accessed using, and have the browser side code open the supplied URL in a new window/tab of the browser?

If this was available, then one could create a fake script xdg-open and put it in the PATH which actually called b url. That way Python applications that use webbrowser.open(), including the b open command, or any other applications that tries to use a similar approach to open a URL in a browser, would be able to work where the terminal session is actually running on a remote system to the browser.

If you think this is technically possibly and can provide pointers of how it could be integrated, then I can have a go at adding support for it. Thanks.

@GrahamDumpleton
Copy link
Contributor Author

My guess at what is needed is to add to butterfly/escapes.py an escape of:

@contextmanager
def url():
    sys.stdout.write('\x1bP;URL|')
    yield
    sys.stdout.write('\x1bP')
    sys.stdout.flush()

and then in function:

and one for URL, which runs window.open(url, '_blank'); or similar.

Can then code up butterfly/bin/url.py to use that.

@GrahamDumpleton
Copy link
Contributor Author

The problem with this is how to do it so as to avoid popup blocker. :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant