dmenu-pubs.sh (raw)
#!/usr/bin/env bash
# To get $SCIPATH to show up at the window manager level, try adding the following to .xsessionrc:
# export SCIPATH=/home/bob/science
pubs_command="pubs -c $SCIPATH/admin/pubs.config"
choice="$(eval "$pubs_command list" | sort --ignore-case | dmenu -l 20 -i)"
status=$?
if [ "$status" -eq "0" ]; then
# Exit code 0
printf "choice: $choice\n"
# From SO: "To include a literal ] in the list, make it the first character (following a possible ^)."
pat="[^][]+"
if [[ "$choice" =~ $pat ]]; then
citekey="${BASH_REMATCH[0]}"
printf "citekey: $citekey\n"
eval "$pubs_command doc open $citekey"
else
printf "no match?\n"
fi
else
# Exit code not 0
printf "not 0\n"
fi