FollieHiyuki-dotfiles/home/.local/bin/fzf/fzbuku

37 lines
698 B
Plaintext
Raw Normal View History

2021-02-13 11:28:59 -05:00
#!/usr/bin/env bash
printf -v jq '.[] | "\(.index) \(.uri) %s\(.tags)%s \(.title)"' "$(tput setaf 7)" "$(tput sgr0)"
main() {
local choice=()
mapfile -t choice < <(buku -p -j |
jq -r "$jq" |
SHELL=bash fzf \
--ansi \
--tac \
--bind='enter:execute(firefox {2})' \
2021-02-13 11:28:59 -05:00
--expect='ctrl-d,ctrl-e' \
--delimiter=' ' \
--height=100% \
--no-hscroll \
--preview-window=down \
--preview='buku -p {1}; lynx -dump {2}' \
--query="$*" \
--with-nth=3..)
selection=${choice[@]:1}
case ${choice[0]} in
ctrl-d)
buku -d ${selection[0]%% *}
main
;;
ctrl-e)
buku -w ${selection[0]%% *}
main
;;
esac
}
main "$*"