Skip to content

Instantly share code, notes, and snippets.

@cKalens
Last active April 9, 2026 13:57
Show Gist options
  • Select an option

  • Save cKalens/bc30f4acced35829c913dcd79c221597 to your computer and use it in GitHub Desktop.

Select an option

Save cKalens/bc30f4acced35829c913dcd79c221597 to your computer and use it in GitHub Desktop.
Fix for IntelliJ IDEA "Use Option as Meta key" auto-enabling bug (Claude Code)
#!/bin/zsh
echo "IntelliJ IDEA Meta Key Fix — Installer"
echo "======================================="
echo ""
setopt nullglob
JBRS=(/Applications/IntelliJ\ IDEA*.app/Contents/jbr/Contents/Home)
if [[ ${#JBRS[@]} -eq 0 ]]; then
echo "⚠️ IntelliJ IDEA not found — agent will not be installed."
echo " Install IntelliJ IDEA and re-run this script."
else
JBR=${JBRS[1]}
echo "✓ JBR: $JBR"
rm -rf ~/.local/share/meta-agent
mkdir -p ~/.local/share/meta-agent
TMPDIR=$(mktemp -d)
cat > "$TMPDIR/DisableMeta.java" << 'JAVA'
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Method;
import java.lang.reflect.Field;
public class DisableMeta {
public static void agentmain(String args, Instrumentation inst) {
try {
Class<?> clazz = null;
for (Class<?> c : inst.getAllLoadedClasses()) {
if (c.getName().equals("org.jetbrains.plugins.terminal.TerminalOptionsProvider")) {
clazz = c;
break;
}
}
if (clazz == null) return;
Method getInst = clazz.getDeclaredMethod("getInstance");
getInst.setAccessible(true);
Object instance = getInst.invoke(null);
Field stateField = clazz.getDeclaredField("state");
stateField.setAccessible(true);
Object state = stateField.get(instance);
for (Field f : state.getClass().getDeclaredFields()) {
if (f.getName().equals("useOptionAsMetaKey")) {
f.setAccessible(true);
f.set(state, false);
break;
}
}
} catch (Exception e) {}
}
}
JAVA
cat > "$TMPDIR/LoadAgent.java" << 'JAVA'
import com.sun.tools.attach.VirtualMachine;
public class LoadAgent {
public static void main(String[] args) throws Exception {
VirtualMachine vm = VirtualMachine.attach(args[0]);
vm.loadAgent(args[1]);
vm.detach();
}
}
JAVA
echo "⏳ Compiling..."
if "$JBR/bin/javac" "$TMPDIR/DisableMeta.java" "$TMPDIR/LoadAgent.java" 2>/dev/null; then
mkdir -p "$TMPDIR/META-INF"
printf "Agent-Class: DisableMeta\nCan-Retransform-Classes: true\n\n" > "$TMPDIR/META-INF/MANIFEST.MF"
(cd "$TMPDIR" && zip -q disable-meta.jar META-INF/MANIFEST.MF DisableMeta.class)
cp "$TMPDIR/DisableMeta.class" "$TMPDIR/LoadAgent.class" "$TMPDIR/disable-meta.jar" ~/.local/share/meta-agent/
echo "✓ Agent: ~/.local/share/meta-agent/"
else
echo "⚠️ Compilation failed — IDE JBR may be corrupted, agent was not installed."
fi
rm -rf "$TMPDIR"
fi
mkdir -p ~/.local/bin
cat > ~/.local/bin/fix-jetbrains-meta << 'SCRIPT'
#!/bin/zsh
setopt nullglob
AGENT_DIR="$HOME/.local/share/meta-agent"
[[ -f "$AGENT_DIR/disable-meta.jar" ]] || exit 0
JBRS=(/Applications/IntelliJ\ IDEA*.app/Contents/jbr/Contents/Home)
[[ ${#JBRS[@]} -eq 0 ]] && exit 0
LOG="$AGENT_DIR/fix.log"
for JBR in "${JBRS[@]}"; do
PIDS=$("$JBR/bin/jps" -l 2>/dev/null | grep "com.intellij" | awk '{print $1}')
[[ -z "$PIDS" ]] && continue
echo "$(date): JBR=$JBR PIDS=$PIDS" >> "$LOG"
for PID in ${(f)PIDS}; do
"$JBR/bin/java" --add-modules jdk.attach -cp "$AGENT_DIR" LoadAgent "$PID" "$AGENT_DIR/disable-meta.jar" >> "$LOG" 2>&1
echo "$(date): PID=$PID EXIT=$?" >> "$LOG"
done
done
SCRIPT
chmod +x ~/.local/bin/fix-jetbrains-meta
echo "✓ Script: ~/.local/bin/fix-jetbrains-meta"
# Clean up old wrapper
if [[ -f ~/.zshrc ]]; then
sed -i '' '/# JetBrains Meta Key fix/,/^}$/d' ~/.zshrc
sed -i '' '/^$/N;/^\n$/d' ~/.zshrc
fi
# Add PATH and wrapper
{
echo ""
echo "# JetBrains Meta Key fix"
echo 'export PATH="$HOME/.local/bin:$PATH"'
cat << 'ZSH'
claude() {
{ sleep 1 && fix-jetbrains-meta } &>/dev/null &!
command claude "$@"
}
ZSH
} >> ~/.zshrc
echo "✓ .zshrc updated (PATH + claude wrapper)"
echo ""
echo "✅ Installation complete!"
echo " Open a new terminal and type 'claude' — Meta Key will be disabled automatically after 1 second."
@cKalens

cKalens commented Apr 9, 2026

Copy link
Copy Markdown
Author

What this does:

This script creates a small Java Agent using IntelliJ's built-in JBR. It runs silently in the background when you type claude, injecting a fix to keep the "Use Option as Meta key" setting disabled, so your @ symbol and other keys keep working.

How to install:

Run the following commands in your terminal:

curl -L -o install-meta-fix.sh "https://gist.githubusercontent.com/cKalens/bc30f4acced35829c913dcd79c221597/raw/install-meta-fix.sh"
chmod +x install-meta-fix.sh
./install-meta-fix.sh

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