是否可以使用~/Library/LaunchAgents/
代理在当前用户的主目录中执行脚本?我目前有(不工作):
<?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>Label</key>
<string>com.puppies</string>
<key>OnDemand</key>
<true/>
<key>RunAtLoad</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>~/script.sh</string>
</array>
<key>StartInterval</key>
<integer>3600</integer></dict>
</plist>
答案 0 :(得分:7)
将EnableGlobbing设置为true:
<key>EnableGlobbing</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>say</string>
<string>~/*</string>
</array>
EnableGlobbing可以在ProgramArguments中扩展波浪号和全局,但不能在Program中扩展。默认情况下,Tildes在WatchPaths和QueueDirectories中进行了扩展。
答案 1 :(得分:1)
执行以下操作
<key>ProgramArguments</key>
<array>
<string>zsh</string>
<string>-c</string>
<string>/bin/sh</string>
<string>~/script.sh</string>
</array>
答案 2 :(得分:1)
我经常在OS X中使用以下内容:
<key>ProgramArguments</key>
<array>
<string>/bin/bash</string>
<string>-c</string>
<string>lb=/Users/`users`/Library;
所以你可以尝试用以下代码替换你的tilda:
/Users/`users`