dotfiles

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README

commit cb14b44c86b87cf9c97f5114ad0d7db157433654
parent 946d281405c396bb6835dbee535ea5b0d9c22dc8
Author: Pablo Cárdenas <pablo.cardenas@imca.edu.pe>
Date:   Wed, 18 May 2022 09:20:11 -0500

Added biburl

Diffstat:
Mlinux/.bash_profile | 3+++
Alinux/.local/bin/bib/bibopen.pl | 20++++++++++++++++++++
Alinux/.local/bin/bib/biburl.pl | 30++++++++++++++++++++++++++++++
Dlinux/.local/bin/bib/main.pl | 19-------------------
Mlinux/.local/bin/bibopen | 12+++++++++++-
Alinux/.local/bin/biburl | 3+++
6 files changed, 67 insertions(+), 20 deletions(-)

diff --git a/linux/.bash_profile b/linux/.bash_profile @@ -25,6 +25,9 @@ export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority export XINITRC="$XDG_CONFIG_HOME"/X11/xinitrc export XSERVERRC="$XDG_CONFIG_HOME"/X11/xserverrc +export BIB="$XDG_CONFIG_HOME/bib/references.bib" +export BIB_DATA="$XDG_DATA_HOME/bib" + source ~/.bashrc export PATH diff --git a/linux/.local/bin/bib/bibopen.pl b/linux/.local/bin/bib/bibopen.pl @@ -0,0 +1,20 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use diagnostics; + +use Text::BibTeX; + +my $bibpath = $ARGV[0]; +my $bibfile = Text::BibTeX::File->new($bibpath); +my $entry; + +while ($entry = Text::BibTeX::Entry->new($bibfile)) { + next unless $entry->parse_ok; + next unless $entry->metatype eq BTE_REGULAR; + my $key = $entry->key; + my $title = $entry->get('title'); + my $author = $entry->get('author'); + print "$key - $title - $author\n"; +} diff --git a/linux/.local/bin/bib/biburl.pl b/linux/.local/bin/bib/biburl.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use diagnostics; + +use Text::BibTeX; + +my $bibpath = $ARGV[0]; +my $bibfile = Text::BibTeX::File->new($bibpath); + +while (my $entry = Text::BibTeX::Entry->new($bibfile)) { + next unless $entry->parse_ok; + next unless $entry->metatype eq BTE_REGULAR; + my $key = $entry->key; + my $title = $entry->get('title'); + my $author = $entry->get('author'); + + my $url; + if ($entry->exists('doi')) { + $url = $entry->get('doi'); + } elsif ($entry->exists('url')){ + $url = $entry->get('url'); + } + else { + next; + } + + print "$url - $title - $author\n"; +} diff --git a/linux/.local/bin/bib/main.pl b/linux/.local/bin/bib/main.pl @@ -1,19 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use diagnostics; - -use Text::BibTeX; - -my $bibfile = Text::BibTeX::File->new('/home/pablo/Documents/references/references.bib'); -my $entry; - -while ($entry = Text::BibTeX::Entry->new($bibfile)) { - next unless $entry->parse_ok; - next unless $entry->metatype eq BTE_REGULAR; - my $key = $entry->key; - my $title = $entry->get('title'); - my $author = $entry->get('author'); - print "$key - $title - $author\n"; -} diff --git a/linux/.local/bin/bibopen b/linux/.local/bin/bibopen @@ -1 +1,11 @@ - ~/.local/bin/bib/main.pl | dmenu -i -l 20 | cut -d" " -f1 | xargs -r -I {} zathura $HOME/Documents/references/{}.pdf +#!/bin/sh + +key=$($HOME/.local/bin/bib/bibopen.pl $BIB| dmenu -i -l 20 | cut -d" " -f1) + +[ -n $key ] || exit + +extensions="pdf djvu" +for ext in $extensions; do + file=$BIB_DATA/$key.$ext + [ -f $file ] && xdg-open $file && break +done diff --git a/linux/.local/bin/biburl b/linux/.local/bin/biburl @@ -0,0 +1,3 @@ +#!/bin/sh + +$HOME/.local/bin/bib/biburl.pl $BIB | dmenu -i -l 20 | cut -d" " -f1 | xclip -selection clipboard