Skip to content

Instantly share code, notes, and snippets.

@focusaurus
Created December 4, 2012 16:55
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 focusaurus/4206139 to your computer and use it in GitHub Desktop.
Save focusaurus/4206139 to your computer and use it in GitHub Desktop.
How I keep OSX plist prefs in my dotfiles repo
#Export like this: prefs export iterm
#import like this: prefs import iterm
prefs() {
local OP="${1}"
shift
case "${OP}" in
export|import);
;;
*)
echo "Usage: prefs <export|import> <app>" 1>&2
return 1
;;
esac
local NAME=$(echo "${1}" | tr A-Z a-z)
local DIR="Library/Preferences"
local PLIST=
case ${NAME} in
*keyboard*|*maestro*|km)
PLIST="Library/Application Support/Keyboard Maestro/Keyboard Maestro Macros.plist"
;;
iterm)
PLIST="${DIR}/com.googlecode.iterm2.plist"
;;
terminal)
PLIST="${DIR}/com.apple.Terminal.plist"
;;
*)
echo "Uknown App name ${1}" 1>&2
return 10
;;
esac
local BIN="${HOME}/${PLIST}"
local XML="${HOME}/projects/dotfiles/${PLIST}"
case "${OP}" in
export)
cp "${BIN}" "${XML}"
plutil -convert xml1 "${XML}"
cd ~/projects/dotfiles
git status
;;
import)
cp "${XML}" "${BIN}"
plutil -convert binary1 "${BIN}"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment