Skip to content

kpenfound/qr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QR Code CLI Generator

A simple and efficient command-line tool for generating QR codes in Go that works perfectly in various terminal sizes and no-tty environments.

Features

  • 🖥️ Terminal-friendly: Automatically detects terminal size and adapts QR code size
  • 🔧 No-TTY support: Works seamlessly when piped or redirected
  • 📱 Multiple output formats: Terminal display or PNG file output
  • Fast and lightweight: Built with Go for optimal performance
  • 🎯 Flexible sizing: Auto-detect or user-friendly size scale (1-10)
  • 🎨 Border control: Configurable border sizes

Installation

go install github.com/kpenfound/qr@latest

Usage

Basic Usage

# Generate QR code for text
qr -text "Hello, World!"

# Using shorthand flag
qr -t "https://example.com"

Advanced Options

# Specify size manually (1-10 scale)
qr -t "Custom size" -s 5

# Save to PNG file
qr -t "Save to file" -o qrcode.png

# Remove border
qr -t "No border" -b 0

# Quiet mode (suppress extra output)
qr -t "Quiet mode" -q

Pipe Input

# Read from stdin
echo "Pipe input" | qr -t -

# Chain with other commands
curl -s https://api.github.com/users/octocat | jq -r .html_url | qr -t -

Command Line Options

Flag Shorthand Default Description
--text -t required Text to encode in QR code
--size -s 0 (auto) Size scale 1-10 (0 for auto-detect, 1=smallest, 10=largest)
--output -o stdout Output PNG file path
--quiet -q false Suppress extra output
--border -b 2 Border size (0 to disable)

Size Options

The size parameter uses a user-friendly scale that maps to valid QR code dimensions:

Size Dimensions Description
1 25×25 Smallest valid QR code
2 29×29 Very small
3 33×33 Small
4 37×37 Small-medium
5 41×41 Medium (good default)
6 45×45 Medium-large
7 49×49 Large
8 53×53 Very large
9 57×57 Extra large
10 61×61 Largest

Note: All sizes produce valid, scannable QR codes. The dimensions correspond to official QR code version standards.

Examples

Terminal Display

qr -t "https://github.com"

Small QR Code

qr -t "Small" -s 1

Medium QR Code

qr -t "Medium" -s 5

Large QR Code without Border

qr -t "Large no border" -s 10 -b 0

Save WiFi Credentials

qr -t "WIFI:T:WPA;S:MyNetwork;P:MyPassword;;" -o wifi.png

Generate from File Contents

cat url_list.txt | head -1 | qr -t - -o first_url.png

License

MIT License

About

QR code generator in the terminal

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages