commit 630a1cdc495dfd42888d91f8724f5314d61987ef
parent 03ae675ca7185cf975d2f7962791519e8478e2b0
Author: Anton Konyahin <me@konyahin.xyz>
Date: Sun, 17 Mar 2024 11:00:54 +0300
base: reorganize directories for use with stow
Diffstat:
7 files changed, 66 insertions(+), 15 deletions(-)
diff --git a/gopher/skefir b/gopher/skefir
@@ -0,0 +1,57 @@
+#!/usr/bin/env sh
+
+set -eu
+
+if [ "$#" -lt 2 ]; then
+ echo "Usage: skefir [-n] <host> <url>"
+ exit 1
+fi
+
+if [ "$1" = "-n" ]; then
+ NO_MAP=true
+ shift
+fi
+
+link () {
+ LINK=$1
+ LINE=$2
+ ARGS=$3
+
+ printf "[%3d] " "$LINK"
+ echo "$LINE" | awk -F '\t' '{print substr($1, 2)}'
+
+ KEFIR_CALL="$(echo "$LINE" | awk -F '\t' '{printf "%s %s", $3, $2}')"
+ COMMAND="$LINK shell skefir $ARGS $KEFIR_CALL"
+ printf "%s\n" "$COMMAND" >> "$LESSKEY_FILE"
+}
+
+viewer () {
+ LINK=1
+ while read -r LINE || [ -n "$LINE" ]; do
+ case "$LINE" in
+ i*)
+ printf " "
+ echo "$LINE" | awk -F '\t' '{print substr($1, 2)}'
+ ;;
+ 1*)
+ link "$LINK" "$LINE" ""
+ LINK=$((LINK + 1))
+ ;;
+ 0*)
+ link "$LINK" "$LINE" "-n"
+ LINK=$((LINK + 1))
+ ;;
+ *)
+ ;;
+ esac
+ done
+}
+
+LESSKEY_FILE=$(mktemp -t skefir.XXXXXX)
+echo "#command" > "$LESSKEY_FILE"
+
+TEXT=$(printf "%s\r\n" "$2" | nc "$1" 70)
+[ -z "${NO_MAP:-}" ] && TEXT="$(echo "$TEXT" | viewer)"
+echo "$TEXT" | less --lesskey-src="$LESSKEY_FILE"
+
+rm "$LESSKEY_FILE"
diff --git a/todotxt/ttxt b/nvi-todotxt/dot-bin/ttxt
diff --git a/todotxt/help b/nvi-todotxt/dot-local/share/nvi/help-todotxt
diff --git a/nvi-todotxt/dot-local/share/nvi/todotxt b/nvi-todotxt/dot-local/share/nvi/todotxt
@@ -0,0 +1,9 @@
+map ;h :!less ~/.local/share/nvi/help-todotxt
+
+map ;n 0:r!date +\%Y-\%m-\%dA
+map ;s :%!sort
+
+map ;t :.!ttxt todo
+map ;m :.!ttxt maybe
+map ;a :.!ttxt active
+map ;d :.!ttxt done
diff --git a/todotxt/nvi b/todotxt/nvi
@@ -1 +0,0 @@
-nvi -c "source ./todotxt" test
diff --git a/todotxt/test b/todotxt/test
@@ -1,5 +0,0 @@
-2023-03-13 some todo
-2023-02-10 another todo
-x completed task
-todo without date
-todo with tag +todo
diff --git a/todotxt/todotxt b/todotxt/todotxt
@@ -1,9 +0,0 @@
-map ;h :!$PAGER ./help
-
-map ;n 0:r!date +\%Y-\%m-\%dA
-map ;s :%!sort
-
-map ;t :.!./ttxt todo
-map ;m :.!./ttxt maybe
-map ;a :.!./ttxt active
-map ;d :.!./ttxt done