commit e16206d6d08f85fdd14a511ebb2118307fc937a1
parent ca1930cad4fcec4a9391c36d66cceea82adf53d4
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Tue, 23 Apr 2019 16:22:02 +0200
Add funcionality to find and add reference from Zathura
Diffstat:
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/.config/zathura/zathurarc b/.config/zathura/zathurarc
@@ -9,3 +9,4 @@ set completion-highlight-bg "#30303a"
set completion-highlight-fg "#aaaaaa"
map <C-o> feedkeys ":exec getdoi --clip '$FILE'<Return>"
+map <C-b> feedkeys ":exec scholarref --add '$FILE'<Return>"
diff --git a/bin/scholarref b/bin/scholarref
@@ -1,3 +1,29 @@
#!/usr/bin/env bash
-set -e
-getdoi "$@" | getref -n
+
+addref=0
+while :; do
+ case "$1" in
+ -a|--add)
+ addref=1
+ ;;
+ --) # end all options
+ shift
+ break
+ ;;
+ -?*)
+ die 'Error: Unknown option specified'
+ ;;
+ *) # No more options
+ break
+ esac
+ shift
+done
+
+if [ "$addref" = 1 ]; then
+ getdoi "$@" | getref -n >> "$BIB"
+ key="$(grep '@.*{' "$BIB" | tail -n 1 | sed 's/.*{//;s/,$//')"
+ echo "Citation $key added to $BIB"
+ notify-send "Citation $key added"
+else
+ getdoi "$@" | getref -n
+fi
diff --git a/bin/shdl b/bin/shdl
@@ -17,7 +17,7 @@ function show_help {
echo " -V, --verbose show verbose information"
echo " -t, --tor-socks use torsocks for requests to sci-hub"
echo " -b, --browser open sci-hub in browser immediately"
- echo " -r, --reference add reference to bibliography using scholarref.py"
+ echo " -r, --reference add reference to bibliography using scholarref"
echo " -n, --notify send desktop notification when complete"
echo " -o, --open open downloaded document when complete"
echo " -- do not consider any following args as options"