blob: e31b6d32974307da352db47e14ad23d3560ccad5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
|