aboutsummaryrefslogtreecommitdiff
path: root/scripts/buku-delete.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2019-01-22 13:11:35 -0200
committerEuAndreh <eu@euandre.org>2019-01-22 13:11:35 -0200
commit3e938ac726a9470083148ef31507e9dc6123ae0c (patch)
tree6f19264f06ca52d6a16efc58175239c3527823b3 /scripts/buku-delete.sh
parentIntegrate buku with newsboat. (diff)
downloaddotfiles-3e938ac726a9470083148ef31507e9dc6123ae0c.tar.gz
dotfiles-3e938ac726a9470083148ef31507e9dc6123ae0c.tar.xz
Setup integration between buku and newsboat.
Diffstat (limited to 'scripts/buku-delete.sh')
-rwxr-xr-xscripts/buku-delete.sh26
1 files changed, 21 insertions, 5 deletions
diff --git a/scripts/buku-delete.sh b/scripts/buku-delete.sh
index 3e2f3dd..552d6b0 100755
--- a/scripts/buku-delete.sh
+++ b/scripts/buku-delete.sh
@@ -1,12 +1,28 @@
#!/usr/bin/env bash
-set -x
-SEL="$(xsel)"
-BOOKMARK_ID="$(buku "$SEL" -f 1 --tacit | tail -n +2 | awk '{print $1}')"
-# tail to trim unwanted "waiting for input" output from buku https://github.com/jarun/Buku/blob/d60d56bc9f7f5e1410e99dc8bb4e35abf5068a14/buku#L4619
+SEL="$(xclip -o | tr -d '\n')"
+if [[ -z "${SEL// }" ]]; then
+ echo "Empty selection."
+ exit 1
+fi
+BOOKMARK_ID=
+IFS="
+"
+BOOKMARKS="$(buku "$SEL" -f 1 --tacit)"
+
+for bookmark in $BOOKMARKS; do
+ echo "$bookmark"
+ ID="$(echo "$bookmark" | cut -d$'\t' -f 1)"
+ URL="$(echo "$bookmark" | cut -d$'\t' -f 2)"
+ if [[ "$URL" = "$SEL" ]]; then
+ BOOKMARK_ID="$ID"
+ break
+ fi
+done
+
if [[ ! -z "$BOOKMARK_ID" ]]; then
- echo "Deleting $BOOKMARK_ID."
+ echo "Deleting $BOOKMARK_ID (URL: $SEL)."
buku -d "$BOOKMARK_ID" --tacit
else
echo "Bookmark for '$SEL' not found."