summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-12-02 08:54:13 -0500
committerBen Sima <ben@bsima.me>2021-12-02 08:54:13 -0500
commit833de4152b3dbb234e5833c901fd4e8696fd8169 (patch)
tree5c607a0a57169af1cfff10ad5c72d1e2f0ab92a7
parentc0862a0adb5a2aceffb5085f6e20e71f87b0bf2e (diff)
add @jb55's reading scripts
-rwxr-xr-xlessr22
-rwxr-xr-xplainweb20
2 files changed, 42 insertions, 0 deletions
diff --git a/lessr b/lessr
new file mode 100755
index 0000000..05469a1
--- /dev/null
+++ b/lessr
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+dir=$(dirname "$1")
+base=$(basename "$1")
+
+if [ "$base" == "" ]; then
+ exit 3
+fi
+
+export LESSHISTFILE="$dir/.$base.hst"
+touch $LESSHISTFILE || :
+
+# use a fallback dir if it's not writable
+if [ ! -w "$LESSHISTFILE" ]
+then
+ dir="$HOME/var/marks"
+ mkdir -p "$dir"
+ export LESSHISTFILE="$dir/.$base.hst"
+fi
+
+# export LESS="-cix8JRM --save-marks"
+exec less --save-marks "$@"
diff --git a/plainweb b/plainweb
new file mode 100755
index 0000000..a10f55a
--- /dev/null
+++ b/plainweb
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+USER_AGENT='User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.15.2 Chrome/83.0.4103.122 Safari/537.36'
+
+if [ -z "$1" ]; then
+ printf "usage: plainweb <url>\n"
+ exit 1
+fi
+
+HURL="/tmp/$(sha256sum <<<"$1" | awk '{print $1}').txt"
+OUT=${2:-$HURL}
+
+if [ ! -f "$HURL" ]; then
+ #w3m -header "$USER_AGENT" -dump "$1" > "$HURL"
+ w3m -dump "$1" > "$HURL"
+fi
+
+exec lessr "$HURL"
+
+