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

Better use of OSC terminal escape codes #1070

Open
kevcube opened this issue Oct 2, 2024 · 6 comments
Open

Better use of OSC terminal escape codes #1070

kevcube opened this issue Oct 2, 2024 · 6 comments
Labels
enhancement New feature or request
Milestone

Comments

@kevcube
Copy link
Contributor

kevcube commented Oct 2, 2024

Is your feature request related to a problem? Please describe.
We are using aws-sso-cli in codespaces, where xdg-open and xsel|xclip etc are not options. We are looking for ways to make the UX as simple as possible for the end users of this codespaces environment.

Describe the solution you'd like
I am requesting options for url-action that can either print the URL to a terminal using OSC 8 escape codes, or copy into clipboard using OSC 52 escape codes. These are both supported by VSCode's integrated terminal, as well as kitty terminal. Not sure about others.

As mentioned, xsel|xclip are not available, so copy to clipboard doesn't work at all over a codespaces/remote connection, but print to terminal obviously works, OSC 8 just gives the opportunity to improve the formatting of these links.

I wish there was an escape code for opening a link in the user's default browser, but I don't see one.

@kevcube kevcube added the enhancement New feature or request label Oct 2, 2024
@kevcube
Copy link
Contributor Author

kevcube commented Oct 2, 2024

ex OSC 8 echo -e "\e]8;;https://example.com\aClick here\e]8;;\a"

ex OSC 52 printf "\e]52;c;$(echo -n 'Text to copy' | base64)\a"

@kevcube
Copy link
Contributor Author

kevcube commented Oct 2, 2024

@synfinatic
Copy link
Owner

iTerm and VSCode terminal both support (on macOS) Command-Click. Not sure what the equivalent would be on Windows/Linux off the top of my head?

Testing echo -e "\e]8;;https://example.com\aClick here\e]8;;\a" in VSCode, basically just rewrites the string to be "Click here" but doesn't remove the need to Command-Click in my experience. Honestly, I'm not really excited by the idea of hiding the URL from the user since IMHO people shouldn't be clicking on random urls for authentication purposes.

As for clipboard support that feature already exists. https://synfinatic.github.io/aws-sso-cli/v1.17.0/config/#browser-urlaction-urlexeccommand

@kevcube
Copy link
Contributor Author

kevcube commented Oct 2, 2024

Honestly, I'm not really excited by the idea of hiding the URL from the user since IMHO people shouldn't be clicking on random urls for authentication purposes.

agreed, but the terminal will provide more context about the full url with a hover. Anyone security-conscious should be checking this, anyone who doesn't care already didn't care.

As for clipboard support that feature already exists. https://synfinatic.github.io/aws-sso-cli/v1.17.0/config/#browser-urlaction-urlexeccommand

Yes it exists. But in a remote shell (ssh or container etc) this error happens:

FATAL   Unable to exec: unable to copy URL to clipboard: No clipboard utilities available. Please install xsel, xclip, wl-clipboard or Termux:API add-on for termux-clipboard-get/set. 

There could be a platform agnostic additional url-action, maybe termclip or something that will use escape codes to copy into the terminal user's clipboard. Because even with one of these utilities installed, it would be copied into the clipboard of the host machine in an ssh example.

@kevcube
Copy link
Contributor Author

kevcube commented Oct 2, 2024

agreed, but the terminal will provide more context about the full url with a hover. Anyone security-conscious should be checking this, anyone who doesn't care already didn't care.

as a CLI, there's already the possibility that you're using escape codes to present a URL as something that it isn't, like echo -e "\e]8;;https://badurl.com\ahttps://goodurl.com\e]8;;\a"

@synfinatic
Copy link
Owner

Regarding "Click me"- Yes. I don't deny that could be happening. Just not sure why I would deliberately obfuscate the actual URL the user should click on? I guess I'm having a hard time imaging there are a set of users who don't know what a URL looks like or when shown one, they don't know what to do with it.

As for clipboard- ah, now I understand the use case. That makes sense.

@synfinatic synfinatic added this to the 2.1.0 milestone Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants