2023-11-30 03:21:48 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
bookmarks="${BOOKMARKS:-"$HOME/.config/qutebrowser/bookmarks/urls"}"
|
|
|
|
|
|
|
|
usage(){
|
|
|
|
printf "Usage: %s -c|h\n" "$(basename $0)"
|
|
|
|
printf "OR\n"
|
|
|
|
printf "Usage: %s <bookmark-url>\n" "$(basename $0)"
|
2023-11-30 15:55:15 +01:00
|
|
|
exit 1
|
2023-11-30 03:21:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
addUrl(){
|
|
|
|
url="$1"
|
|
|
|
|
|
|
|
if [ "$(grep "$url" "$bookmarks")" ]
|
|
|
|
then printf "Bookmark of url '%s' already exists\n" "$url" && exit 1
|
|
|
|
else printf "%s %s\n" \
|
|
|
|
"$url" \
|
|
|
|
"$(curl -s "$url" | grep '<title' | sed 's/<title>\(.*\)<\/title>/\1/')" \
|
|
|
|
>> $bookmarks
|
|
|
|
fi
|
2023-12-08 16:55:40 +01:00
|
|
|
printf "added '%s' to '%s\n'" "$url" "$bookmarks"
|
2023-11-30 03:21:48 +01:00
|
|
|
}
|
|
|
|
|
2023-11-30 15:55:15 +01:00
|
|
|
|
2023-11-30 15:57:01 +01:00
|
|
|
while getopts ch flag; do
|
2023-11-30 03:21:48 +01:00
|
|
|
case $flag in
|
2023-11-30 15:55:15 +01:00
|
|
|
c)addUrl $(xclip -o) && exit 0;;
|
2023-11-30 03:21:48 +01:00
|
|
|
h)usage;;
|
|
|
|
esac
|
|
|
|
done
|
2023-11-30 15:55:15 +01:00
|
|
|
|
|
|
|
addUrl $1
|