bin/neovide-fix.sh (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#!/bin/zsh
# Make Neovide.app start through a wrapper that sources ~/.zshrc, so the GUI
# app sees the same PATH and environment as a terminal, then re-sign the app.
#
# Re-run after every Neovide update: the update replaces the app bundle and
# undoes this. Needs sudo, for the re-signing.
set -euo pipefail
app='/Applications/Neovide.app'
# Create wrapper if it doesn't exist
cat > "${app}/Contents/MacOS/neovide-wrapper.sh" <<'EOF'
#!/bin/zsh
source ~/.zshrc
exec "$(dirname "$0")/neovide" "$@"
EOF
chmod +x "${app}/Contents/MacOS/neovide-wrapper.sh"
# Update plist to use wrapper
/usr/libexec/PlistBuddy -c "Set :CFBundleExecutable neovide-wrapper.sh" "${app}/Contents/Info.plist"
# Clear code signature
sudo xattr -cr "${app}"
# Re-sign the app
sudo codesign --force --deep --sign - "${app}"
# Verify signature
codesign -dv "${app}"
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f "${app}"
echo "Neovide fixed!"
|