From 70e6d80c2d367480478eacf46363ee88a0e994ff Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 29 Jan 2026 01:27:17 +0100 Subject: added lots of new dmenu scripts --- citekey-menu | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 citekey-menu (limited to 'citekey-menu') diff --git a/citekey-menu b/citekey-menu new file mode 100755 index 0000000..3b94bbe --- /dev/null +++ b/citekey-menu @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +BIB="${BIB:-/home/lukasz/thesis_main/05_thesis/bibliography.bib}" +DMENU="${DMENU:-dmenu -i -l 20 -p Citekey}" +CLIP="${CLIP:-xclip -selection clipboard}" + +if [[ ! -r "$BIB" ]]; then + printf "ERROR: cannot read %s\n" "$BIB" >&2 + exit 1 +fi + +# Build menu lines: "typecitekey" +choices="$( + rg -n '^\@(\w+)\{([^,]+),' "$BIB" \ + | sed -E 's/^[0-9]+:\@(\w+)\{([^,]+),/\1\t\2/' \ + | sort -u +)" + +picked="$(printf "%s\n" "$choices" | eval "$DMENU" || true)" +[[ -z "$picked" ]] && exit 0 + +key="$(printf "%s" "$picked" | awk -F'\t' '{print $2}')" +[[ -z "$key" ]] && exit 0 + +printf "[@%s]" "$key" | eval "$CLIP" +printf "Copied: [@%s]\n" "$key" >&2 + -- cgit v1.3