Create a gist now

Instantly share code, notes, and snippets.

@tgray /yoadd
Created May 2, 2013

What would you like to do?
#!/bin/sh -
# Adds the first argument (a URL) to yojimbo as a bookmark. Using the -a
# switch, one can add it as a web archive instead. Optional arguments 2 and 3
# can be used to set the title and the comment of the bookmark. These have no
# effect if making a web archive.
#
# Originally designed to import newsbeuter bookmarked items into yojimbo
print_help()
{
echo "usage: yoadd [<options>] url [title] [comment]"
echo
echo "Add URLs to Yojimbo."
echo
echo "options:"
echo " -a, --archive make a web archive"
echo " -b, --bookmark make a bookmark"
echo " -h, --help print help"
}
case $1 in
-a | --archive)
yojitem="web archive"
shift
;;
-b | --bookmark)
yojitem="bookmark"
shift
;;
-h | --help)
print_help
exit 0
;;
*)
yojitem="bookmark"
;;
esac
url="$1"
title="$2"
desc="$3"
if [ "$yojitem" == "bookmark" ]
then
# catch blank titles
if [ -z $title ]
then
title=$url
fi
osascript <<EOF
tell application "Yojimbo"
set bmark to make new bookmark item with properties {name:"$title",location:"$url",comments:"$desc"}
add tags {"from RSS"} to bmark
end tell
EOF
elif [ "$yojitem" == "web archive" ]
then
osascript <<EOF
tell application "Yojimbo"
set bmark to make new web archive item with contents "$url"
add tags {"from RSS"} to bmark
end tell
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment