浏览代码

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>
Celestino Gomes 1 年之前
父节点
当前提交
e583648195
共有 2 个文件被更改,包括 25 次插入0 次删除
  1. 8 0
      plugins/qrcode/README.md
  2. 17 0
      plugins/qrcode/qrcode.plugin.zsh

+ 8 - 0
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"`

+ 17 - 0
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"
+}