Skip to content

Instantly share code, notes, and snippets.

@EdieLemoine
Created May 23, 2023 10:13
Show Gist options
  • Save EdieLemoine/a20af730723563366f829ba892a6af54 to your computer and use it in GitHub Desktop.
Save EdieLemoine/a20af730723563366f829ba892a6af54 to your computer and use it in GitHub Desktop.
Patches GitHub Copilot for IntelliJ plugin to work with any IDE version
#!/usr/bin/env bash
###
# This script will patch the IntelliJ Copilot plugin to work with any version of IntelliJ IDEs.
# - Download the latest plugin from https://plugins.jetbrains.com/plugin/17718-github-copilot/versions/stable
# - Run ./this-script.sh <path-to-plugin-jar>
# Example: ./this-script.sh github-copilot-intellij-1.0.0.jar
# - The patched plugin will be located at ./copilot-plugin/github-copilot-intellij-1.0.0.jar.
###
file=$1
last_dir=$(pwd)
working_dir="copilot-plugin"
rm -rf "${working_dir}"
unzip $file -d "${working_dir}"
cd "${working_dir}"
unzip github-copilot-intellij/lib/github-copilot-intellij-*.jar
sed -i -E 's/until-build="[0-9.*]*"/until-build="999\.\*"/g' META-INF/plugin.xml
zip -r github-copilot-intellij/lib/github-copilot-intellij-*.jar META-INF/
rm -r META-INF
zip -r ../$file github-copilot-intellij/
rm -r github-copilot-intellij
cd $last_dir
echo "The plugin has been patched and is located at $last_dir/${file}."
@nafg
Copy link

nafg commented May 23, 2023

  1. Can we automate downloading the latest plugin?
  2. Can we automate installing it into IntelliJ (like the "Get" button on the plugin page)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment