dockprof/dockprof
2015-01-15 21:47:40 -05:00

60 lines
1.5 KiB
Bash
Executable file

#!/usr/bin/env bash
case $# in
1|2)
if [ $1 == reset ]; then
read -p 'Are you sure you want to reset your dock to the factory defaults (y/n)? ' -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
defaults delete com.apple.dock
killall Dock
fi
else
case $1 in
save|load)
if [ -z $2 ]; then
echo 'Error: You must specify a profile name'
exit 1
else
LOADED=~/Library/Preferences/com.apple.dock.plist
PROFILE=~/Library/Preferences/$2.com.apple.dock.plist
if [ $1 == save ]; then
if [ -e $PROFILE ]; then
read -p "Would you like to overwrite the profile '$2' (y/n)? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo 'Save aborted'
exit
fi
fi
defaults export $LOADED $PROFILE
else
if [ ! -e $PROFILE ]; then
echo 'Error: Profile does not exist'
exit 1
else
defaults delete $LOADED
defaults import $LOADED $PROFILE
killall Dock
fi
fi
fi
;;
*)
echo 'Error: Invalid command, expecting reset, save or load'
exit 1
;;
esac
fi
;;
*)
echo 'Usage: dockprof [reset|save|load] [profile]'
exit 1
;;
esac