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
David JULIEN 28dfdd5ae5 feat: change shebang to /usr/bin/env sh
this setting is more user-config compliant
2021-02-12 23:20:57 +01:00

26 lines
970 B
Bash
Executable File

#!/usr/bin/env sh
######################################################################
# @author : swytch
# @file : bibshow
# @license : MIT
# @created : Wednesday May 20, 2020 17:58:14 CEST
#
# @description : interactively display the infos in a .bib entry
# @dependencies : dmenu
######################################################################
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
refs_list="$(sed -e 's/\t//g' "$file" | tr '\n' ' ' | sed -e 's/}\s\s/}\n/g')"
[ -z $refs_list ] && exit 1;
ref="$(printf "$refs_list" | dmenu -i -p 'reference?' -l 10)"
[ -z $ref ] && exit 1;
output="$(printf "$ref" | sed -e 's/author/\n author/g' -e 's/",/",\n/g')"
printf "$output" | dmenu -i -p "infos" -l 10
printf "$ref" | awk -F '{' '{print $2}' | awk -F ',' '{print $1}' | xclip -selection clipboard