diff options
| author | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukasz.kasprzak@pm.me> | 2026-04-14 22:32:43 +0200 |
| commit | 83f7fe4b8402bab171d110703a1b1115efbc9b28 (patch) | |
| tree | 19110702c7d740f6bd8ee4f5d2ebcb97442be237 /citekey-menu | |
| parent | 51d43498b07dc97d795947964534f0903cd05db5 (diff) | |
| download | bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.tar.gz bin-83f7fe4b8402bab171d110703a1b1115efbc9b28.zip | |
cleaned up many scrits and deleted some that were of no use; renamed a lot
Diffstat (limited to 'citekey-menu')
| -rwxr-xr-x | citekey-menu | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/citekey-menu b/citekey-menu index 3b94bbe..d8db51e 100755 --- a/citekey-menu +++ b/citekey-menu @@ -1,8 +1,9 @@ #!/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}" +BIB="${BIB:-/home/lukasz/git/thesis_main/05_thesis/bibliography.bib}" +DMENU_KEY="${DMENU_KEY:-dmenu -i -l 20 -p Citekey}" +DMENU_LOC="${DMENU_LOC:-dmenu -i -p 'Locator (optional)'}" CLIP="${CLIP:-xclip -selection clipboard}" if [[ ! -r "$BIB" ]]; then @@ -17,12 +18,20 @@ choices="$( | sort -u )" -picked="$(printf "%s\n" "$choices" | eval "$DMENU" || true)" +picked="$(printf "%s\n" "$choices" | eval "$DMENU_KEY" || 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 +# Optional locator, e.g. 84 / 11-13 / xxi +locator="$(printf '\n' | eval "$DMENU_LOC" || true)" +if [[ -n "${locator// }" ]]; then + citation="[@$key, $locator]" +else + citation="[@$key]" +fi + +printf "%s" "$citation" | eval "$CLIP" +printf "Copied: %s\n" "$citation" >&2 |
