commit 43b579050a185251014465c4c69b250414429281
parent 8eed4c525970941cee7d721c885c492747fe1a65
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Wed, 27 Jan 2021 10:22:34 +0100
add scripts to grab urls and reverse file contents
Diffstat:
3 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/.local/bin/extract_urls b/.local/bin/extract_urls
@@ -0,0 +1,8 @@
+#!/usr/bin/awk -f
+{
+ if (match($0, /(http|https|ftp|gopher):\/\/[A-z0-9\-\/\.\?=%]+[^ .,:\t\n\r<">\)]/)) {
+ url = substr($0, RSTART, RLENGTH)
+ if (!urls[url]++)
+ print url
+ }
+}
diff --git a/.local/bin/reverse b/.local/bin/reverse
@@ -0,0 +1,9 @@
+#!/usr/bin/awk -f
+{
+ line[i++] = $0
+}
+
+END {
+ while (i > 0)
+ print line[--i]
+}
diff --git a/.local/bin/urlgrab b/.local/bin/urlgrab
@@ -0,0 +1,14 @@
+#!/bin/sh
+set -e
+pid=$(xprop | awk '/_NET_WM_PID/ { print $3 }')
+f="${HOME}/.cache/st/$(date +%Y-%m-%d)/"*".$pid"
+urls="$(cat $f | extract_urls)"
+if [ -z "$TERM" -o "$TERM" = linux -o "$TERM" = dumb ]; then
+ menu="dmenu -i"
+else
+ menu="fzy"
+fi
+c="$(printf '%s\n' "$urls" | $menu)"
+if [ "$c" ]; then
+ plumb "$c"
+fi