Created
May 2, 2013 15:41
-
-
Save tgray/5503112 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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