Disables the reopening of applications and windows for modern MacOS versions. For some reason on the latest Sierra patch, my apps and windows are reopening.
#!/bin/bash
# curl https://gist.githubusercontent.com/inoicouldalwaysturn2u/69042c23228578a6725a298ae5ac7fe2/raw/9c6b3d51281c9e7d3883fbc644aa968fe1768a01/disable-reopening-apps-windows-MacOS-modern-versions-post-Lion -L -s -o ~/.local/bin/fixlogin.sh
# chmod +x ~/.local/bin/fixlogin.sh && sudo ~/.local/bin/fixlogin.sh ; rm ~/.local/bin/fixlogin.sh
echo "#!/bin/bash" > /tmp/loginfix.sh
echo "rm /Users/*/Library/Preferences/ByHost/com.apple.loginwindow.*" >> /tmp/loginfix.sh
mv /tmp/loginfix.sh /usr/local/bin/loginfix.sh
chmod +x /usr/local/bin/loginfix.sh
defaults write com.apple.loginwindow LoginHook /usr/local/bin/loginfix.sh