summaryrefslogtreecommitdiff
path: root/plugins/qrcode
diff options
context:
space:
mode:
authorCelestino Gomes <tinorj@gmail.com>2023-01-09 17:46:54 -0300
committerGitHub <noreply@github.com>2023-01-09 20:46:54 +0000
commite583648195a33afb6ec4ebddb1926570a9a5e475 (patch)
tree5089b7e250bf60bc78eb9b504f77c4acbdd9b5ba /plugins/qrcode
parent046f0ca5571e28aa328566d5f81a338e074cf174 (diff)
downloadzsh-e583648195a33afb6ec4ebddb1926570a9a5e475.tar.gz
zsh-e583648195a33afb6ec4ebddb1926570a9a5e475.tar.bz2
zsh-e583648195a33afb6ec4ebddb1926570a9a5e475.zip
feat(qrcode): new plugin to generate qrcode via https://qrcode.show (#10247)
* feat(qrcode): new plugin to generate qrcode via https://qrcode.show * code fix suggested by @JuniorJPDJ * Update docs to clarify how to interact with it Co-authored-by: Robby Russell <robby@planetargon.com>
Diffstat (limited to 'plugins/qrcode')
-rw-r--r--plugins/qrcode/README.md8
-rw-r--r--plugins/qrcode/qrcode.plugin.zsh17
2 files changed, 25 insertions, 0 deletions
diff --git a/plugins/qrcode/README.md b/plugins/qrcode/README.md
new file mode 100644
index 000000000..bcc870541
--- /dev/null
+++ b/plugins/qrcode/README.md
@@ -0,0 +1,8 @@
+# QRCode plugin
+
+Generate a QR Code from the command line. Uses [QRcode.show](https://qrcode.show) via curl.
+
+alias | command
+--------------- | --------
+`qrcode [text]` | `curl -d "text" qrcode.show`
+`qrsvg [text]` | `curl -d "text" qrcode.show -H "Accepct: image.svg"`
diff --git a/plugins/qrcode/qrcode.plugin.zsh b/plugins/qrcode/qrcode.plugin.zsh
new file mode 100644
index 000000000..d757e135e
--- /dev/null
+++ b/plugins/qrcode/qrcode.plugin.zsh
@@ -0,0 +1,17 @@
+# Imported and improved from https://qrcode.show/, section SHELL FUNCTIONS
+
+_qrcode_show_message() {
+ echo "Type or paste your text, add a new blank line, and press ^d"
+}
+
+qrcode () {
+ local input="$*"
+ [ -z "$input" ] && _qrcode_show_message && local input="@/dev/stdin"
+ curl -d "$input" https://qrcode.show
+}
+
+qrsvg () {
+ local input="$*"
+ [ -z "$input" ] && _qrcode_show_message && local input="@/dev/stdin"
+ curl -d "$input" https://qrcode.show -H "Accept: image/svg+xml"
+}