summaryrefslogtreecommitdiff
path: root/utils/cliphist-img.sh
diff options
context:
space:
mode:
Diffstat (limited to 'utils/cliphist-img.sh')
-rw-r--r--utils/cliphist-img.sh15
1 files changed, 15 insertions, 0 deletions
diff --git a/utils/cliphist-img.sh b/utils/cliphist-img.sh
new file mode 100644
index 0000000..8fe8c2c
--- /dev/null
+++ b/utils/cliphist-img.sh
@@ -0,0 +1,15 @@
+tmp_dir="/tmp/cliphist-img"
+
+mkdir -p "$tmp_dir"
+
+read -r -d '' prog <<EOF
+/^[0-9]+\s<meta http-equiv=/ { next }
+match(\$0, /^([0-9]+)\s(\[\[\s)?binary.*(jpg|jpeg|png|bmp)/, grp) {
+ path="$tmp_dir/"grp[1]"."grp[3]
+ system("echo " grp[1] "\\\\\t | cliphist decode >" path)
+ print path
+ next
+}
+EOF
+
+cliphist list | gawk "$prog"