浏览代码

Adding support for stdin input in the encode64 plugin

Sébastien Larivière 9 年之前
父节点
当前提交
7daa207dbc
共有 1 个文件被更改,包括 15 次插入2 次删除
  1. 15 2
      plugins/encode64/encode64.plugin.zsh

+ 15 - 2
plugins/encode64/encode64.plugin.zsh

@@ -1,4 +1,17 @@
-encode64(){ printf '%s' $1 | base64 }
-decode64(){ printf '%s' $1 | base64 --decode }
+encode64() {
+    if [[ $# -eq 0 ]]; then
+        cat | base64
+    else
+        printf '%s' $1 | base64
+    fi
+}
+
+decode64() {
+    if [[ $# -eq 0 ]]; then
+        cat | base64 --decode
+    else
+        printf '%s' $1 | base64 --decode
+    fi
+}
 alias e64=encode64
 alias d64=decode64