April 29, 2016

Accessing Accordance from the Command Line in Terminal

I was talking with someone today about how you might grab a text reference from Accordance without leaving the command line in Terminal. So, I thought I'd share one way to accomplish it.


You can use Applescript to retrieve the full text of verse references from a given text module, all without bringing Accordance to the front or interacting with its interface in any way. This is how my old scripts and actions have worked, as well as some the OS X Services that OakTree packages with Accordance.
A raw Applescript line to get the text of John 1:1 from the NRSVS module using the citation format (true) is:

tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}
You can call that from the shell using osascript:

osascript -e 'tell app "Accordance" to get «event AccdTxRf» {"NRSVS", "John 1:1", true}'
But, no-one wants to type that out each time you want to lookup a verse, so you'll want to create a shell script that passes the verse reference as an argument to the script. Here's an example:
------------------------------------
#!/bin/bash

# This script takes a verse reference as an argument to return the full text of the reference to stdout
# chmod +x getverse.sh 
# ./getverse.sh

# set the short name of module to use
modulename="NRSVS"
# set to "true" to use citation format
usecitation="true"

# trap for a null argument passed, since Accordance crashes if it receives a null parameter
if [ -n "$*" ] #[ "$#" -gt 0 ] 
then
# retrieve all passed arguments as one string, so you can pass references with spaces and without quotes: John 1:1
verseref="$*"

# get the text of the reference from Accordance
textresult=$(osascript -e "tell app \"Accordance\" to get «event AccdTxRf» {\"$modulename\", \"$verseref\", $usecitation}")

echo "$textresult"

else
    echo "Must pass a text reference as a variable, as in:  getverse John 1:1"
fi
------------------------------------
Save that as a text file in your home folder ( ~/ ) with a name like 'getverse.sh'. You'll also need to make it executable by going to the Terminal and using:

chmod +x getverse.sh
After that, you can call the script from the command line in Terminal with:

./getverse.sh John 11:35

An additional, welcome, step is to create an alias that calls that script, to further reduce what you have to type to run it.  Open up your bash profile at ~/.bash_profile (it likely doesn't exist yet, so you'll have to create it),  and then add a line to it to create the alias:

alias gv=./getverse.sh
After that, you'll need to initiate the bash shell environment with this command in Terminal:

source ~/.bash_profile
Then, you can just type: gv John 1:1, 3
to lookup your verse references.

I glossed over some details, assuming that if you're at all interested in doing what this post suggests, you are already familiar with the subjects and functions covered.


April 01, 2016

New Tesla Design Makes It the Apple of Autos

Tesla is the high-end electric car company, headed by an eccentric and high-profile CEO, that makes the incredible electric car that so many want but so few can afford. This has earned them the moniker "the Apple of Automobiles".
Tesla made big news today for revealing the design of their Model 3, which is still in production, but will start at $35,000. In just a day, 115,000 people have reserved their car, all based on the dramatic release of this one photo. Just take a look at the design photo they released, and you can see what has so many people excited:

Tesla Model 3
I am excited about this.
The single photo offers a limited scope of what's in store for the newest electric car, but a couple things revealed here have me thrilled. Immediately most controversial I suspect would be the two discreet passenger compartments. The world of tech and social sciences both have skyrocketed into the pursuit of specialization, so the inevitable result is division between passengers and operators. Several may find this off-putting, but I have two kids, and it strikes me as genius.

You can also notice Jobsesque attention to detail, such as the step ladder and the doubled headlights. Many have already been speculating about the extra headlights. What could they be for? Extra visibility. Some are suggesting that the second pair of headlights could be designed to shift the light spectrum away from intense blue light after 10pm.
The company is not saying much more, other than the availability of a few luxury and tech-related add-on options. The most intriguing the description of a deck, that then became associated with this (leaked?) picture.

They are calling an "eight track deck". I assume it is some sort of audio (bluetooth?) interface that allows you to connect up to eight iOS devices at once. At the press release, a design engineer Max Campbell was very enthusiastic about this technology.
Here's my speculation: could this new car, along with this add-on, be some type of coordination between Tesla and Apple into the new frontier of self-driving cars? Maybe you set up the directions on your phone, and then just plug it into the deck and the car takes over from there?  One can dream.

Without much revealed, we'll have to wait for more info, though that's not preventing auto and tech pundits alike from already drawing their own conclusions.
Technology aficionado John Gruber tweeted this about the upcoming car: "I think it has a classic, almost Homeric quality."

March 03, 2016

Script to Paste Clipboard with Specific Font

A friend asked about a script to copy selected text and paste it into Word in a specified font face. My mind explodes with all the different ways, technologies one could do this with—Applescript, Automator, VBA within Word, and launcher/macro programs like KeyboardMaestro and Quicksilver.

Let's say you found the relevant text or from a PDF or website or in Accordance and you want to copy and paste it into your Word document, but you want to specify the font because it's a different language than your other normal text.*

I'd like to illuminate one little trick I learned some time ago that can be incorporated into several of those. Namely, you can use the command line textual tool to markup the text with the much-maligned HTML tag and then copy it to the clipboard converting the HTML text to styled text. The syntax for the line is:
echo '<i>I am some italicized text</i>' | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf
I normally would wrap that into a script which grabs the text and then pastes it wherever I want it. Here's an example of a script, which copies the selected text in the front app, then reads the clipboard into variable, adds a tag to the text of the variable, then copies that newly-styled text back onto the clipboard, and then brings Word to the front, and pastes the directly formatted text.

-- copy the text
tell application "System Events"
keystroke "c" using {command down}
end tell
delay 0.1
set myText to the clipboard
delay 0.1

-- add HTML style data to the text
set myText to "<font face=\"SBL BibLit\" size=3>" & myText"</font>"

-- convert the styled html text as styled text on the clipboard
do shell script "echo " & quoted form of myText & ¬
" | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"

-- paste the newly styled keyboard into an app
tell application "Microsoft Word"
activate
tell application "System Events"
keystroke "v" using {command down}
end tell

end tell

You could, of course, convert much of this script into Automator or other macro environment.

Another way of accomplishing this for Word would be to have the script set the Font info for the current selection point in Word, strip any style data from the clipboard, then Paste and Match Style the text into Word.

* Note: I would suggest that the best practice for writing in Word is to use Styles to format the document, not direct formatting. You could have a script environment that pasted a text and then selected that text and then set the style for that text using VBA or Applescript.

January 12, 2016

Taming the Symbols in Accordance

In the latest release of Accordance Bible software, one of the new features is the addition of Highlight Symbols. These function identically to previous word highlighting, but place instead symbols below words you attach them to. The image set that comes included in Accordance is clearly intended to be kid friendly (fun?). As a result, the color choices are not unified and lack any consistent style. So, if you find the image palette rather unpalatable, just alter them.
To find the resource folder of the images:

  1. Right-click or Control-click on the Accordance application icon in a Finder window.
  2. Select "Show Package Contents"
  3. Navigate to /Contents/Resources/  where you will see a "watermarks' folder with images 1 thru 130.
  4. Backup that folder elsewhere to be safe.
  5. Quit Accordance and have fun editing the images.

You can download a set of updated images that you see in this post. They add a consistent bluish-greyish color theme on top of Accordance's default images. You can install them by dragging the icons into the watermarks folder you navigated to. The images are available here.



Note: Here's an example of doing the same kind of thing in Dropbox, altering images in the application bundle to customize your look.



November 06, 2015

Accordance Web Browser Bookmarklets

Tired of all those scripture links on web pages opening up in biblegateway? Looking for a quick way to look up some text in your browser not in wikipedia, but in your Accordance tool?

Since Accordance has added the new URL Links (accord://) protocol, it has enabled new ways of interacting with Accordance, even while working in other applications. The URL Links are designed primarily for you to add links to Accordance modules in your own webpages and documents, handy indeed, especially now that you can even URL Link to a specific point in an Accordance module (as of 11.1). For more information on URL Links, visit the very informative help page on the topic.

However, there's an additional way of making use of URL Links: incorporating them into bookmarklets. Bookmarklets are a way to code advanced functionality into the bookmarks/favorites saved in your web browser (Safari, Chrome, Firefox, etc.).
This trick allows you to select text in a web page or pdf that's open in your web browser, and then select the Accordance Bookmarklet that searches based on that text. This essentially duplicates the functionality available in the Accordance Services, but they're much quicker when in your browser:

  • reading a selected verse reference in either the default text or a specified text
  • searching for a selected word or phrase in either the default text or a specified text
  • searching for a selected word in any of your Accordance tools within a stated search field
  • looking up the study topic function of either a verse list or an article from the default study tool
In the table below are a series of Accordance Bookmarklets to get you started. You can drag any of these links into the "Favorites Bar" (as it's called in Safari) or "Bookmarks Bar" (as it's called in Chrome). Then, you simply select the text in a web document and then click the Bookmarklet you wish. In Safari, you can also use the keyboard shortcut Command ⌘ + Option ⌥ + 1, 2, 3, etc. to activate the corresponding bookmarklet in the bar.

Open a verse selection to read in Accordance
ReadVerses = Open the verse selection in your default text module.
Open the verse selection in a specifically named text module:
ReadNRSVS ReadNIV ReadESVS
Search for a selected word or phrase in an Accordance text
SearchWords = Search for the selection in the default text module.
Search for the selection in a specifically named text module:
SearchNRSVS SearchNIV SearchESVS
Search a specific search field of a specified tool module:
SearchAnchorEntry = Search for the selected text in the Entry field of the Anchor Bible Dictionary.
SearchAnchorEnglish = Search for the selected text in the English Content field of the Anchor Bible Dictionary.
SearchNIB-NTReference = Search for the selected text in Reference field of the New Interpreter's Bible NT.
Search the Study Topic function in Accordance
StudyTopicVerses = Display a list of verses related to the selected topic.
StudyTopicArticle = Show an article on the selected topic.

You can test out your Bookmarklets.
Let's say you want to research, say:  dung
Just highlight the word and click the appropriate bookmarklet.
Same goes for looking up a text reference, such as:  John 11:35   or    Micah 6:8

You can customize a bookmarklet by right-clicking (control-clicking) on the bookmark in the bar and select "edit address". At the end of the long javascript address, you'll see where you can alter the Accordance URL Link.

Here is a video showing how to install, use and edit the bookmarklets: