This is a knock-off of the Mac OS X defaults program, but able to manipulate nested dicts.
Long-term, I'll likely abandon this project in favor of an Ansible plugin, something like ansible/ansible-modules-extras#2392.
It needs Python 3 and PyObjC (pyobjc-framework-Cocoa, for CoreFoundation).
Homebrew's Python won't let pip install packages into it, so the easiest way
is to run it with uv, which provides both:
uv run --with pyobjc-framework-Cocoa ./defaults+ read com.apple.Terminal 'Window Settings.Basic'Or add the dependency to the script itself, so uv runs it directly:
uv add --script defaults+ pyobjc-framework-Cocoa
sed -i '' '1s|.*|#!/usr/bin/env -S uv run --quiet --script|' defaults+To get all the settings for the Basic profile in Terminal:
defaults+ read com.apple.Terminal 'Window Settings.Basic'To add a setting to that profile (to disable the audible bell feature):
defaults+ write com.apple.Terminal 'Window Settings.Basic.Bell' 0To read the setting you just wrote:
defaults+ read com.apple.Terminal 'Window Settings.Basic.Bell'To copy one Terminal profile to another:
defaults+ copy com.apple.Terminal 'Window Settings.Basic' 'Window Settings.Copy of Basic'
defaults+ write com.apple.Terminal 'Window Settings.Copy of Basic.name' 'Copy of Basic'- Add
deletecommand. - Add
renamecommand. - Add other types of items for
write.- data
- bool, float, etc.
- array, dict
- array-add, dict-add
- with and without flag explicitly specifying type
- Add
read-typecommand. - Require a flag to overwrite an array or hash with a single value.
- Handle a top-level key that doesn't exist, or isn't a dict (it crashes now).
- Accept
-app Terminalsyntax for the domain. - Accept the same
<value_rep>syntax thatdefaultsdoes. - Allow specifying the key path separator.
- Do real command-line option parsing and help.
Copyright (c) 2014 Craig Buchek
Copyright (c) 2014 BoochTek, LLC
This software is licensed under the terms of the MIT License. See LICENSE.txt for details.
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin my-new-feature). - Create new Pull Request.