From fe5153e69f5afa2b3a12c9f06095ada30420e63f Mon Sep 17 00:00:00 2001 From: Nanda Lopes Date: Sun, 28 Mar 2021 19:41:19 -0300 Subject: [PATCH] Buku examples to select and mass update, open or edit. tested on Ubuntu, zsh and bash compatible --- Examples.md | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/Examples.md b/Examples.md index 1409b26..d5e7d26 100644 --- a/Examples.md +++ b/Examples.md @@ -1495,18 +1495,54 @@ function drmi() { ### buku Search and open website bookmarks stored in a [buku](https://github.com/jarun/Buku) database. + ```sh +# BUKU bookmark manager +# get bookmark ids +get_buku_ids() { + buku -p -f 5 | fzf --tac --layout=reverse-list -m | \ + cut -d $'\t' -f 1 + # awk -F= '{print $1}' + # cut -d $'\t' -f 1 +} + +# buku open fb() { # save newline separated string into an array - mapfile -t website <<< "$(buku -p -f 5 | column -ts$'\t' | fzf --multi)" + ids=( $(get_buku_ids) ) - # open each website - for i in "${website[@]}"; do - index="$(echo "$i" | awk '{print $1}')" - buku -p "$index" - buku -o "$index" + echo buku --open ${ids[@]} + + [[ -z $ids ]] && return 1 # return error if has no bookmark selected + + buku --open ${ids[@]} +} + +# buku update +fbu() { + # save newline separated string into an array + ids=( $(get_buku_ids) ) + + echo buku --update ${ids[@]} $@ + + [[ -z $ids ]] && return 0 # return if has no bookmark selected + + buku --update ${ids[@]} $@ +} + +# buku write +fbw() { + # save newline separated string into an array + ids=( $(get_buku_ids) ) + # print -l $ids + + # update websites + for i in ${ids[@]}; do + echo buku --write $i + buku --write $i done } + ``` ...And a nicer looking alternative, using [fzfmenu](#fzf-as-dmenu-replacement).