QR Codes on the Command-Line
Why QR codes?
QR codes aren’t magical, they boil down to:
- 2d encoding of information
(1000s of characters depending on encoding and error correction) - machine readability
(especially with the supercomputing cameras in our pockets)
but, for my own personal uses, it’s just one of the fastest way to securely transfer small amount of data, (e.g. URLs or passwords), from my computer to my phone.
To use QR codes, you don’t even need networking! It’s too bad that wifi network login was never widely adopted, it’s one of the most useful use cases for QR out there.
As of January 2018, iPhones have this feature (wifi network login) built into the camera app under iOS 11.x […]
Whoah… that wasn’t true when I started playing with this!
I just checked and it works 🤯
On the command-line
Get the qrencode package:
To generate a QR code, dumping it to stdout
as ASCII art:
but that’s a lot to type; put it in your dotfiles as a function:
There’s a bunch of output formats: PNG, PNG32, EPS, SVG, XPM, ANSI, ANSI256, ASCII, ASCIIi, UTF8, ANSIUTF8. Feel free to experiment 😃
On the phone
I’m on iOS and I’ve been using Barcode. It gives you a contextual menu when it finds a QR code:
- text: copy to clipboard, share
- URL: copy to clipboard, share, open in safari/chrome
I hadn’t realized that QR codes can be read directly in the iOS camera app… thank you Apple! It’s a bit finicky (try it, you’ll see what I mean) but it works.