From 8321c0e378204ed93e391b1ec3933aabe28e757d Mon Sep 17 00:00:00 2001
From: ryo <ryo@nopwd.lol>
Date: Tue, 17 Dec 2024 00:15:40 +0000
Subject: Added null.sh and zathura plus some fixes

In scripts don't specify dash but just sh.
Removed bc from aliases.
Changed pocket to dl.
---
 bin/null.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)
 create mode 100755 bin/null.sh

(limited to 'bin/null.sh')

diff --git a/bin/null.sh b/bin/null.sh
new file mode 100755
index 0000000..938913c
--- /dev/null
+++ b/bin/null.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+# ==== DELETE THIS LINES =====
+echo "NOTHING HAPPENED!"
+echo "FIRST READ THE SCRIPT!"
+exit
+# ============================
+
+set -e
+
+host="https://x.nopwd.lol"
+links="$HOME/.local/null-links.txt"
+exp="1"
+sec=""
+prog="${0##*/}"
+
+usage() {
+	cat <<-_EOF
+	Usage:
+		  $prog [option] [file|url]
+		
+	Options:
+		  -l			long link
+		  -s			shorten url
+		  -e [hour]		expire time
+		
+	Examples:
+		  # upload file
+		  $prog somefile.png
+
+		  # expire time 24 hours
+		  $prog -e 24 somefile.png
+		
+		  # upload piped data
+		  echo "something" | $prog -
+		
+		  # get long link
+		  $prog -l somefile.png
+		
+		  # shorten url
+		  $prog -s https://verylongurl
+
+		  # combine expire and long
+		  $prog -e 5 -s somefile.txt
+	_EOF
+	exit
+}
+
+if [ $1 = "-e" ]; then
+	exp=$2
+	shift 2
+fi
+
+if [ $# -ge 3 ] || [ $# -eq 0 ]; then
+	usage
+fi
+
+if [ $# -eq 2 ]; then
+	case $1 in
+	-s)
+		url=$(curl -s -Fshorten=$2 $host)
+		echo $url
+		echo -e "$url\t# shorten: $2" >> $links
+		exit
+		;;
+	-l)
+		long="secret="
+		shift
+		;;
+	*)
+		echo "$prog: unrecognized option '$1'"
+		usage
+		;;
+	esac
+fi
+
+if [ -f $1 ] || [ $1 = "-" ]; then
+	out=$(curl -s -Ffile=@$1 -F$long -Fexpires=$exp -w '%header{x-token}' $host)
+else
+	echo "$prog: file '$1' not exist"
+	exit
+fi
+
+url=$(echo "$out" | sed '1q;d')
+token=$(echo "$out" | sed '2q;d')
+
+echo $url
+echo -e "$url\t\t# expire: $exp, token: $token" >> $links
-- 
cgit v1.2.3