#yaml #default #macos #user #declarative

app apply-user-defaults

一个使用 YAML 文件声明性设置 macOS 用户默认值的小工具

3 个版本

0.1.2 2020 年 1 月 9 日
0.1.1 2019 年 12 月 14 日
0.1.0 2019 年 12 月 12 日

#108macOS 和 iOS API

Download history 7/week @ 2024-02-14 38/week @ 2024-02-21 3/week @ 2024-02-28 3/week @ 2024-03-06 24/week @ 2024-03-13

每月 72 次下载

MIT/Apache

17KB
202

Build Status License Crates.io

apply-user-defaults

apply-user-defaults 是一个使用 YAML 文件声明性设置 macOS 用户默认值的小工具。

用法

要使用它,只需像以下结构 YAML 文件

com.apple.dock:
  # System Preferences > Dock > Automatically hide and show the Dock.
  autohide: true

  # System Preferences > Dock > Minimize windows using: Scale effect.
  mineffect: "scale"

  # System Preferences > Dock > Show indicators for open applications.
  show-process-indicators: false

  # System Preferences > Dock > Size.
  tilesize: 72

然后使用以下命令应用它

$ apply-user-defaults path-to-file.yaml

您还可以通过启用详细输出查看正在运行的命令

$ apply-user-defaults path-to-file.yaml --verbose
==> defaults write com.apple.dock autohide -bool true
==> defaults write com.apple.dock mineffect -string scale
==> defaults write com.apple.dock show-process-indicators -bool false
==> defaults write com.apple.dock tilesize -int 72
Success! Applied defaults.

模板扩展

您还可以使用 shell 参数扩展语法包含环境变量。例如

com.apple.finder:
  # Finder > Preferences > New Finder windows show > Home directory.
  NewWindowTargetPath: "file://${HOME}"

将评估为

defaults write com.apple.finder NewWindowTargetPath -string "file://$HOME"

其中 $HOMEHOME 环境变量中的值。

这仅适用于 YAML 文件中的字符串以美元符号开头并括在括号内时(仅使用 $HOME 不会工作)。

要禁用,您可以传递标志 --no-env 或转义美元符号,例如 '\\${VALUE}'

安装

预编译的二进制文件可在 发布页面 上找到。

Homebrew

如果您使用 Homebrew,则可以使用自定义 tap 进行安装

$ brew install zero-sh/tap/apply-user-defaults

Cargo 安装

要通过 Cargo 安装,运行

$ cargo install apply-user-defaults

从源代码构建

要构建源代码

$ git clone https://github.com/zero-sh/apply-user-defaults.git
$ cd apply-user-defaults
$ cargo run -- path-to-file.yml --verbose

许可证

本项目根据您的选择,采用 Apache-2.0 许可证或 MIT 许可证。

除非您明确声明,否则任何有意提交以包含在本作品中的贡献,根据 Apache-2.0 许可证定义,均应双重许可如上所述,不附加任何额外条款或条件。

依赖项

~3–12MB
~113K SLoC