This repository contains two bash scripts to export and import macOS defaults (plist
) files across different locations such as Dropbox, iCloud, Box, WorkDocs, or a custom directory. These scripts provide flexibility with various storage options or custom paths.
- export_defaults.sh: Exports all macOS defaults into
.plist
files. - import_defaults.sh: Imports previously exported
.plist
files back into macOS defaults.
- These scripts require macOS and the use of the
defaults
command. - Ensure you have permissions to read/write in the specified directories.
Be cautious when running the import_defaults.sh
script, especially on systems where defaults are already set. The script will overwrite any existing settings for the domains specified in the .plist
files being imported. This means:
- Existing system or app settings may be replaced with the values in the
.plist
files. - There is no undo option, so ensure that you have a backup of your current settings before running the script.
It's a good idea to export the current defaults using export_defaults.sh
before importing new settings, to have a reference or backup of your current configuration.
-
Clone the repository from GitHub:
git clone https://github.com/brokosz/macos-defaults-scripts.git
-
Navigate into the cloned repository:
cd macos-defaults-scripts
-
Make the scripts executable:
chmod +x export_defaults.sh chmod +x import_defaults.sh
-
(Optional) Move the scripts to a directory in your
$PATH
to use them globally:sudo mv export_defaults.sh /usr/local/bin/export_defaults sudo mv import_defaults.sh /usr/local/bin/import_defaults
This allows you to run the scripts from anywhere using
export_defaults
andimport_defaults
.
The export_defaults.sh
script exports macOS defaults to the specified directory. If no directory is specified, it defaults to ~/.config/defaults
. If a custom directory is specified but doesn't exist, the script will create it automatically.
./export_defaults.sh [custom_output_directory] [options]
-d, --dropbox
: Use Dropbox default output directory (~/Dropbox/config/defaults
).-i, --icloud
: Use iCloud default output directory (~/Library/Mobile Documents/com~apple~CloudDocs/config/defaults
).-wd, --workdocs
: Use WorkDocs default output directory (~/Library/CloudStorage/WorkDocsDrive-Documents/config/defaults
).-b, --box
: Use Box.com default output directory (~/Library/CloudStorage/Box-Documents/config/defaults
).-h, --help
: Display help information.
-
Export to Dropbox:
./export_defaults.sh -d
-
Export to iCloud:
./export_defaults.sh -i
-
Export to a custom directory (if it doesn’t exist, it will be created):
./export_defaults.sh /path/to/custom/dir
The import_defaults.sh
script imports macOS defaults from .plist
files in the specified directory. If no directory is specified, it defaults to ~/.config/defaults
.
./import_defaults.sh [custom_input_directory] [options]
-d, --dropbox
: Use Dropbox default input directory (~/Dropbox/config/defaults
).-i, --icloud
: Use iCloud default input directory (~/Library/Mobile Documents/com~apple~CloudDocs/config/defaults
).-wd, --workdocs
: Use WorkDocs default input directory (~/Library/CloudStorage/WorkDocsDrive-Documents/config/defaults
).-b, --box
: Use Box.com default input directory (~/Library/CloudStorage/Box-Documents/config/defaults
).-h, --help
: Display help information.
-
Import from Dropbox:
./import_defaults.sh -d
-
Import from iCloud:
./import_defaults.sh -i
-
Import from a custom directory:
./import_defaults.sh /path/to/custom/dir
You can specify a custom path directly. The script will automatically detect if the first argument is a valid directory path and use it for the operation. If the custom directory doesn't exist, it will be created automatically.
./export_defaults.sh /path/to/custom/dir
./import_defaults.sh /path/to/custom/dir
This project is licensed under the MIT License. See the LICENSE file for more details.