blob: 5e59a39b3b1f12dc1d22fcf808a8c7bead5c15eb (
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
|
#!/bin/sh
#
# docs.sh
#
# Usage: docs.sh
#
# Opens a pdf's specific page with zathura using a references file
# The syntax of the references file must be:
# Name#Absolute path to pdf#Page number
# The only character with any logic is #, used to separate fields
# Lines starting directly with # are comments
# Empty lines are ignored
# Name can be anything and is just used for selection with dmenu
referencesFile="$HOME/.config/zathura/refs"
lines="$(wc -l "$referencesFile")"
if reference="$(sed '/^#/d' "$referencesFile" | sed '/^\s*$/d' | cut -d# -f1 |
dmenu -l "$lines" -p "Reference: ")"; then
line="$(grep "$reference" "$referencesFile" | sed q)"
file="$(echo "$line" | cut -d# -f2)"
page="$(echo "$line" | cut -d# -f3)"
if [ -n "$page" ]; then
zathura -P "$page" "$file" &
else
zathura "$file" &
fi
fi
|