aboutsummaryrefslogtreecommitdiff
path: root/jumper.sh
diff options
context:
space:
mode:
authorfoswret <foswret@posteo.com>2026-04-05 16:55:20 -0500
committerfoswret <foswret@posteo.com>2026-04-05 16:55:20 -0500
commit06e39ee847cb3a06cd6f5926f00f2b0a1864ea77 (patch)
treebe0d929ba0d934069d85dc76e991e975a815f9d0 /jumper.sh
initial commit
Diffstat (limited to 'jumper.sh')
-rwxr-xr-xjumper.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/jumper.sh b/jumper.sh
new file mode 100755
index 0000000..e31b6d3
--- /dev/null
+++ b/jumper.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+# jumper: Plaintext bookmark launcher
+# https://foswret.com
+
+browser=/bin/librewolf
+
+if [ -z "$1" ]; then
+ echo "Error: no bookmark file specifed."
+ exit 1
+fi
+
+filename="$1"
+
+
+# If a position file is specified
+if [ "$2" ]; then
+ position="$2"
+fi
+
+increment=0
+
+# If a specific postion is specified
+if [ "$position" ]; then
+ while IFS=" " read -r field comment; do
+ case $field in
+ # If the line starts with a "#" (comment)
+ \#*)
+ continue
+ ;;
+ *[!\ ]*)
+ increment=$((increment+1))
+ if [ "$position" = "$increment" ]; then
+ $browser "$field"
+ exit 0
+ fi
+ ;;
+ # If $field is only whitespace (blank line)
+ *)
+ continue
+ ;;
+ esac
+done < "$filename"
+echo "Error: position $position unknown."
+exit 1
+fi
+
+while IFS=" " read -r field comment; do
+ case $field in
+ # If the line starts with a "#" (comment)
+ \#*)
+ continue
+ ;;
+
+ *[!\ ]*)
+ increment=$((increment+1))
+ printf "(%d)" "$increment"
+ if [ "$comment" ]; then
+ printf " %s:" "$comment"
+ fi
+ printf " %s" "$field"
+ printf "\n"
+ ;;
+
+ # If $field is only whitespace (blank line)
+ *)
+ continue
+ ;;
+esac
+done < "$filename"
+
+exit 0