This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/.local/bin/bibshow

25 lines
969 B
Plaintext
Raw Normal View History

#!/usr/bin/env sh
2020-05-06 03:20:19 +02:00
######################################################################
2021-02-14 19:07:45 +01:00
# @author : swytch
# @file : bibshow
# @license : GPLv3
2021-02-14 19:07:45 +01:00
# @created : Wednesday May 20, 2020 17:58:14 CEST
#
2021-02-14 19:07:45 +01:00
# @description : interactively display the infos of a .bib entry in dmenu
######################################################################
2020-05-06 03:20:19 +02:00
file="$(find $HOME/documents/bibliographies/ -type f -not -path '*/\.*' | dmenu -l 20 -p "[bibshow] which bibliography?")" # the -not -path allows find to ignore hidden files
2020-09-06 21:49:07 +02:00
refs_list="$(sed -e 's/\t//g' "$file" | tr '\n' ' ' | sed -e 's/}\s\s/}\n/g')"
2021-06-12 19:21:54 +02:00
[ -z "$refs_list" ] && exit 1;
2020-05-06 03:20:19 +02:00
ref="$(printf "$refs_list" | dmenu -i -p 'reference?' -l 10)"
2021-06-12 19:21:54 +02:00
[ -z "$ref" ] && exit 1;
2020-05-06 03:20:19 +02:00
output="$(printf "$ref" | sed -e 's/author/\n author/g' -e 's/",/",\n/g')"
2020-05-06 03:20:19 +02:00
printf "$output" | dmenu -i -p "infos" -l 10
2021-06-12 19:21:54 +02:00
printf "$ref" | awk -F '{' '{print $2}' | awk -F ',' '{print $1}' | tr -d '\n' | xclip -selection clipboard