Skip to content

Instantly share code, notes, and snippets.

@kcking
Created July 19, 2017 20:20
Show Gist options
  • Save kcking/f4d3668a620433c9f9588f3e7201638c to your computer and use it in GitHub Desktop.
Save kcking/f4d3668a620433c9f9588f3e7201638c to your computer and use it in GitHub Desktop.
Test git config launched from launchctl
#!/bin/sh
rm /tmp/launchctl_gitconfig.log 2> /dev/null
cat > ~/Library/LaunchAgents/gitconfig_test.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
<plist version="1.0">
<dict>
<key>Label</key>
<string>git_config_test</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>/usr/local/bin/git config --global user.name && /usr/local/bin/git config --global user.email</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/launchctl_gitconfig.log</string>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/gitconfig_test.plist
sleep 1
cat /tmp/launchctl_gitconfig.log
launchctl unload ~/Library/LaunchAgents/gitconfig_test.plist
rm ~/Library/LaunchAgents/gitconfig_test.plist
rm /tmp/launchctl_gitconfig.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment