Browse Source

added fzbuku

pull/8/merge
DanielFGray 6 months ago
parent
commit
0b5d8e9cc1
2 changed files with 55 additions and 0 deletions
  1. 4
    0
      README.md
  2. 51
    0
      fzbuku

+ 4
- 0
README.md View File

@@ -14,6 +14,10 @@ Interactive git wrapper. Very much still a work in progress, but it has some ver

*depends on `git` and `perl`*

## [fzbuku](fzbuku)

A small wrapper around [buku](https://github.com/jarun/Buku) to search bookmarks

## [fzmp](fzmp)

Lists and searches for songs in an MPD library by artist, album, or playlist. I wrote a [blog post](https://danielfgray.gitlab.io/computers/fzmp) about writing this script.

+ 51
- 0
fzbuku View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash

_video() {
x-terminal-emulator -t mpv -e "mpv '$1'"
}
export -f _video

_open() {
case $1 in
*youtube.com*) _video "$1" ;;
*youtu.be*) _video "$1" ;;
*vimeo.com*) _video "$1" ;;
*) x-www-browser "$1" ;;
esac
}
export -f _open

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: _open {2}' \
--expect='ctrl-d,ctrl-e' \
--delimiter=' ' \
--height=100% \
--no-hscroll \
--preview-window=down \
--preview='buku -p {1}; w3m {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 "$*"

Loading…
Cancel
Save