Added new script
Allows for the addition of bookmarks outside of Qutebrowser
This commit is contained in:
parent
f0188e98be
commit
7a16b51b8d
30
src/bin/add-bookmark
Executable file
30
src/bin/add-bookmark
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/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)"
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
while getopts chu: flag; do
|
||||
case $flag in
|
||||
c)addUrl $(xclip -o);;
|
||||
u)addUrl $OPTARG;;
|
||||
h)usage;;
|
||||
esac
|
||||
done
|
Loading…
Reference in a new issue