Set the WorkingDirectory to user's home in launchd?

I understand that you can change a LaunchAgent's working directory with a WorkingDirectory key, but is there any way to set the Working Directory to a user's home directory reliably and portably within the plist? Can I do something like:

<key>WorkingDirectory</key>
    <string>~</string>

and have it work?


Solution 1:

launchd doesn't know about shell mechansims like ~ or $HOME. Instead you can use one of the following

  • Specify the full path in the plist
  • Add cd $HOME at the beginning of the executedscript