我正在编写一个引导脚本来自动化新开发人员的 Mac 计算机的一些设置。到目前为止,我已经能够使用以下命令从命令行安装 SP brew cask
:
brew cask install sequel-pro
是否可以从命令行创建 SP“收藏夹”,例如,新开发人员已经可以在他/她的指尖获得本地 Vagrant 框的连接参数?
Sequel Pro 将其收藏夹存储在~/Library/Application Support/Sequel Pro/Data/Favorites.plist
,密码存储在钥匙串中。所以我必须做两件事:
通过查看我 current 的内容Favorites.plist
,我想出了这个基本的启动文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Favorites Root</key>
<dict>
<key>Children</key>
<array>
<dict>
<key>database</key>
<string>my_db_name</string>
<key>host</key>
<string>127.0.0.1</string>
<key>id</key>
<integer>-4414284772604805500</integer>
<key>name</key>
<string>homestead</string>
<key>port</key>
<string>33060</string>
<key>socket</key>
<string></string>
<key>sshHost</key>
<string></string>
<key>sshKeyLocation</key>
<string></string>
<key>sshKeyLocationEnabled</key>
<integer>0</integer>
<key>sshPort</key>
<string></string>
<key>sshUser</key>
<string></string>
<key>sslCACertFileLocation</key>
<string></string>
<key>sslCACertFileLocationEnabled</key>
<integer>0</integer>
<key>sslCertificateFileLocation</key>
<string></string>
<key>sslCertificateFileLocationEnabled</key>
<integer>0</integer>
<key>sslKeyFileLocation</key>
<string></string>
<key>sslKeyFileLocationEnabled</key>
<integer>0</integer>
<key>type</key>
<integer>0</integer>
<key>useSSL</key>
<integer>0</integer>
<key>user</key>
<string>homestead</string>
</dict>
</array>
<key>IsExpanded</key>
<true/>
<key>Name</key>
<string>FAVORITES</string>
</dict>
</dict>
</plist>
我将它保存Favorites.plist
在与我的引导脚本相同的目录中(如原始问题中所述),并将以下 3 行添加到脚本中:
mkdir -p ~/Library/Application\ Support/Sequel\ Pro/Data/
cp -f Favorites.plist ~/Library/Application\ Support/Sequel\ Pro/Data/
security add-generic-password -U -T "/Applications/Sequel Pro.app" -s "Sequel Pro : homestead (-4414284772604805500)" -a homestead@127.0.0.1/my_db_name -w secret
Favorites.plist
(名称、数据库、id 等)中的元素对齐。security
命令的文档。中提琴!