#!/usr/bin/env bash set -euo pipefail ADD_TAG="need review" add() { if [[ $1 =~ (https|ftp|file):// ]]; then index=$(buku --nostdin --json --add "$1" | jq .index) if [ -n "$index" ]; then buku -u "$index" --tag + "$ADD_TAG" fi return 0 fi return 1 } main() { local url if [ $# -eq 0 ]; then url="$(xsel -ob)" else url="$1" fi if add "$url"; then alert "URL added: $url" else alert "URL error: $url" fi } main "$@"