This repository contains two enhanced bash scripts to export and import macOS defaults (plist) files across different locations such as Dropbox, iCloud, Box, WorkDocs, OneDrive, Mega, Google Drive, network drives, or custom directories. These scripts provide flexibility with various storage options, comprehensive error handling, progress tracking, and cross-machine compatibility features.
- export_defaults.sh: Exports all macOS defaults into
.plistfiles. - import_defaults.sh: Imports previously exported
.plistfiles back into macOS defaults.
- Automatic backups: Creates timestamped backups before importing
- Cloud service validation: Checks if cloud storage apps are installed and synced
- Write permission testing: Validates directory access before operations
- Dry run mode: Preview operations without making changes
- Cross-machine compatibility: Handles architecture and macOS version differences
- Real-time progress bars: Visual progress tracking during operations
- Detailed summaries: Comprehensive reports of what was changed
- Verbose logging: Optional detailed output for troubleshooting
- Color-coded messages: Clear visual feedback with info, warning, and error messages
- Multiple cloud services: Dropbox, iCloud, OneDrive, Google Drive, Mega, Box, WorkDocs
- Network drives: Support for SMB, AFP, and mounted volumes
- Custom directories: Use any local or network path
- Automatic path detection: Finds cloud service folders automatically
- Change detection: Only imports settings that have actually changed
- Machine information tracking: Records source machine details for compatibility
- Selective processing: Skip unchanged domains to speed up imports
- Force import option: Override change detection when needed
- These scripts require macOS and the use of the
defaultscommand. - Ensure you have permissions to read/write in the specified directories.
- For cloud services, make sure the respective apps are installed and synced.
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
.plistfiles. - 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
$PATHto 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_defaultsandimport_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).-od, --onedrive: Use OneDrive default output directory (~/Library/CloudStorage/OneDrive-Personal/config/defaults).-gd, --googledrive: Use Google Drive default output directory (~/Library/CloudStorage/GoogleDrive-*/config/defaults).-mg, --mega: Use Mega default output directory (~/MEGAsync/config/defaults).-n, --network PATH: Use network path (SMB/AFP/mounted volume).-m, --modifiers: Include keyboard modifier key settings.--dry-run: Show what would be exported without doing it.--no-backup: Skip creating backup of existing directory.-v, --verbose: Enable verbose output.-h, --help: Display help information.
-
Export to Dropbox:
./export_defaults.sh -d
-
Export to iCloud:
./export_defaults.sh -i
-
Export to OneDrive:
./export_defaults.sh -od
-
Export to Mega:
./export_defaults.sh -mg
-
Export to Google Drive:
./export_defaults.sh -gd
-
Export to a network drive:
./export_defaults.sh -n /Volumes/NetworkDrive
-
Preview export to iCloud (dry run):
./export_defaults.sh --dry-run -i
-
Export with verbose output and modifier keys:
./export_defaults.sh -d -m -v
-
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).-od, --onedrive: Use OneDrive default input directory (~/Library/CloudStorage/OneDrive-Personal/config/defaults).-gd, --googledrive: Use Google Drive default input directory (~/Library/CloudStorage/GoogleDrive-*/config/defaults).-mg, --mega: Use Mega default input directory (~/MEGAsync/config/defaults).-n, --network PATH: Use network path (SMB/AFP/mounted volume).-m, --modifiers: Include keyboard modifier key settings.--dry-run: Show what would be imported without doing it.--no-backup: Skip creating backup of current settings.--force: Import all settings even if unchanged.-v, --verbose: Enable verbose output.-h, --help: Display help information.
-
Import from Dropbox:
./import_defaults.sh -d
-
Import from iCloud:
./import_defaults.sh -i
-
Import from OneDrive:
./import_defaults.sh -od
-
Import from Mega:
./import_defaults.sh -mg
-
Import from OneDrive:
./import_defaults.sh -od
-
Import from Mega:
./import_defaults.sh -mg
-
Import from Google Drive:
./import_defaults.sh -gd
-
Import from a network drive:
./import_defaults.sh -n /Volumes/NetworkDrive
-
Preview import from iCloud (dry run):
./import_defaults.sh --dry-run -i
-
Force import all settings with verbose output:
./import_defaults.sh --force -v -d
-
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/dirThe scripts support various network storage options:
- SMB shares:
./export_defaults.sh -n /Volumes/MyNAS - AFP shares:
./export_defaults.sh -n /Volumes/AppleShare - Mounted volumes: Any path under
/Volumes/
Make sure the network drive is mounted before running the scripts.
When importing settings between different machines, the scripts automatically:
- Check architecture compatibility (Intel vs Apple Silicon)
- Warn about macOS version differences
- Handle machine-specific UUIDs for modifier keys
- Create machine information files for reference
- Automatic backups: Current settings are backed up before import
- Timestamped backups: Each backup has a unique timestamp
- Manual restore: Use the backup files to restore previous settings
Example backup location: ~/.config/defaults_backup_20241201_143022/
Cloud service not found
- Make sure the cloud storage app is installed and synced
- Check that the sync folder exists in the expected location
Permission denied
- Ensure you have write permissions to the target directory
- For network drives, check your network credentials
Import fails silently
- Use
--verboseflag to see detailed output - Check if the plist files are valid using
plutil -lint filename.plist
Settings don't take effect
- Some applications need to be restarted
- Try logging out and back in for system-wide settings
- Use
killall cfprefsdto refresh the preferences daemon
Use the --help flag for detailed usage information:
./export_defaults.sh --help
./import_defaults.sh --helpUse --dry-run to preview operations without making changes:
./import_defaults.sh --dry-run -iThis project is licensed under the MIT License. See the LICENSE file for more details.