Skip to content

Instantly share code, notes, and snippets.

@pmbauer
Created June 22, 2022 03:25
Show Gist options
  • Save pmbauer/bd16b780ee59ec2caeb6257dfd50b7c2 to your computer and use it in GitHub Desktop.
Save pmbauer/bd16b780ee59ec2caeb6257dfd50b7c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# NOTE: you will need node installed (for npx asar)
# NOTE: this works on MacOS.
# You'll need to modify MAIN_ASAR and CACHE_DIR for your platform
MAIN_ASAR=/Applications/Obsidian.app/Contents/Resources/obsidian.asar
CACHE_DIR="/Users/$USER/Library/Application Support/obsidian"
TARGET_ASAR=$((ls -r "$CACHE_DIR"/obsidian-*.asar 2>/dev/null || echo "$MAIN_ASAR") | head -n 1)
TMP_ASAR=/tmp/obsidian.asar
UNPACKED_ASAR=/tmp/obsidian.asar.unpacked
# cleanup
rm -rf $TMP_ASAR $UNPACKED_ASAR
npx asar extract "$TARGET_ASAR" /tmp/obsidian.asar.unpacked
# Remove emacs keybindings and conflicting Mod-[ mapping
sed -i 's/{key:"Ctrl-b".*key:"Ctrl-v"[^}]*}//;s/{key:"Mod-\["[^}]*},//' "$UNPACKED_ASAR"/app.js
npx asar pack $UNPACKED_ASAR $TMP_ASAR
# replace with patched asar
pkill Obsidian
cp $TMP_ASAR "$TARGET_ASAR"
@pmbauer
Copy link
Author

pmbauer commented Jun 22, 2022

CM6 broke vim keybindings, see

This hack patches things for Obsidian.

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