Created
December 4, 2012 16:55
-
-
Save focusaurus/4206139 to your computer and use it in GitHub Desktop.
How I keep OSX plist prefs in my dotfiles repo
This file contains hidden or 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
#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