Overview
Theqr command reads content from standard input (stdin) and generates a QR code that can be scanned with mobile devices. It’s perfect for quickly sharing URLs, text, or data between devices.
Syntax
Parameters
This command takes no parameters. It reads all input from stdin.Usage Examples
Output
The command displays a QR code in the terminal using ASCII/Unicode characters:How It Works
QR Code Generation
- Reads all content from stdin
- Generates a QR code containing the content
- Renders the QR code to the terminal
- Can be scanned by any QR code reader app
Data Encoding
The QR code can encode:- Plain text (up to ~4,296 characters)
- URLs (automatically recognized by QR readers)
- Contact information (vCard format)
- WiFi credentials (special format)
- Any other text-based data
Common Use Cases
Sharing Tunnel URLs
Thetunnel and serve commands automatically generate QR codes for their URLs, but you can also manually generate them:
WiFi Sharing
Share WiFi credentials that mobile devices can scan to connect:T: Security type (WPA, WEP, or blank for open)S: Network SSIDP: Password
Quick URL Sharing
Contact Information
vCard format for contact sharing:Technical Details
Implementation
The command:- Uses a QR code generation library
- Renders using terminal-compatible characters
- Outputs directly to stdout
- Supports all standard QR code error correction levels
Character Limitations
Terminal Display
The QR code is rendered using:- Unicode block characters for better definition
- Black and white contrast
- Automatic sizing based on content length
Error Handling
No Input
If run without piped input:Ctrl+D to signal end of input.
Content Too Large
If the input exceeds QR code capacity, the generation may:- Fail with an error
- Create a very large QR code that’s difficult to scan
- Truncate the content (depending on implementation)
Keep content concise for best scanning results. URLs work well, but large text blocks may be problematic.
Best Practices
URL Shortening
For long URLs, consider using a URL shortener first:Terminal Size
Ensure your terminal is large enough to display the QR code:- Maximize terminal window
- Reduce font size if needed
- Use a terminal with good Unicode support
Lighting and Scanning
For best scanning results:- Ensure good terminal contrast
- Avoid terminal transparency
- Position camera straight-on to the screen
- Adjust screen brightness if needed
Related Commands
- tunnel - Automatically generates QR codes for tunnel URLs
- serve - Automatically generates QR codes for server URLs
- clip - Copy content to clipboard instead
Notes
The
tunnel and serve commands automatically generate and display QR codes for their URLs, so you typically don’t need to use this command separately for those use cases.QR codes displayed in the terminal can be scanned directly from the screen using any QR code reader app on a mobile device.
