tmate-io / tmate

Instant Terminal Sharing
https://tmate.io/
Other
5.55k stars 298 forks source link

Output the connection URL in machine readable (barcode) format? #297

Closed martlin2cz closed 2 weeks ago

martlin2cz commented 8 months ago

Hello, I was just wondering whether the connection URL (or the whole command) could be (optionally) outputed in a way a smartphone camera can quickly scan that by the barcode/QR scanner instead of typing the long generated string of characters on the tiny smartphone keyboard.

I guess there exists some ASCII-art based QR or barcode generating library which could get utilised for that purpose.

Regards

lgrn commented 5 months ago

Assuming you can fetch the part you want as a QR code yourself, you can use qrencode to generate a QR code in a terminal:

$ echo "hello world" | qrencode -t UTF8 -o -
█████████████████████████████
█████████████████████████████
████ ▄▄▄▄▄ █▀▄█▀▄█ ▄▄▄▄▄ ████
████ █   █ █▀▄█▀██ █   █ ████
████ █▄▄▄█ █▀▀ ▄ █ █▄▄▄█ ████
████▄▄▄▄▄▄▄█▄█ ▀ █▄▄▄▄▄▄▄████
████▄ ▄▄▄▀▄▄ ▄██  ▀ ▀ ▀▄▀████
████ █▄▄██▄▀█ ▀▄█ ▄█▀  ▄█████
████▄▄███▄▄█▀▄ ▄▀▄▄█▀▀██ ████
████ ▄▄▄▄▄ █▄▄ █▄▀▄▀█▀ ▄█████
████ █   █ █  ▀█▀▀  ▀▀█▄▄████
████ █▄▄▄█ █ █▀█ ▀█▄▀▀ ██████
████▄▄▄▄▄▄▄█▄▄█▄▄█▄█▄██▄█████
█████████████████████████████
█████████████████████████████
martlin2cz commented 2 weeks ago

Oh, amazing idea. Just to provide full solution, here may be the full command, (execute within your running session):

$ tmate display -p '#{tmate_ssh}' | tr -d 'ssh ' | qrencode -t UTF8 -o -

to display only the ssh command address or:

$ tmate display -p '#{tmate_web}' | qrencode -t UTF8 -o -

for the URL of the web view.