#!/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