summaryrefslogtreecommitdiff
path: root/bin/neovide-fix.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/neovide-fix.sh')
-rwxr-xr-xbin/neovide-fix.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/neovide-fix.sh b/bin/neovide-fix.sh
new file mode 100755
index 0000000..f8d92ad
--- /dev/null
+++ b/bin/neovide-fix.sh
@@ -0,0 +1,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!"
+