Skip to content

Instantly share code, notes, and snippets.

@mronkko
Created July 9, 2012 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mronkko/3078345 to your computer and use it in GitHub Desktop.
Save mronkko/3078345 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Locate profile directory.
if [ -e ~/Library/Application\ Support/Zotero/profiles.ini ]
then
echo "Found Zotero Standalone profile"
PROFILEBASE=~/Library/Application\ Support/Zotero/
elif [ -e ~/Library/Application\ Support/Firefox/profiles.ini ]
then
echo "Found Firefox profile"
PROFILEBASE=~/Library/Application\ Support/Firefox/
else
echo "Could not locate Firefox or Zotero Standalone profile"
exit 1
fi
# Parse the default profile
DEFAULTPROFILE="$PROFILEBASE`cat "$PROFILEBASE/profiles.ini" | grep -B 1 "Default=1" | head -n1 | sed 's/Path=//'`"
# Parse preferences
if [ -e "$DEFAULTPROFILE/prefs.js" ]
then
cat "$DEFAULTPROFILE/prefs.js" | grep "extensions.zotero.dataDir" | sed 's/user_pref(\"extensions.zotero.dataDir\", \"\(.*\)\");/\1/'
else
echo "Could not read Zotero preferences"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment