Created
June 22, 2022 03:25
-
-
Save pmbauer/bd16b780ee59ec2caeb6257dfd50b7c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CM6 broke vim keybindings, see
This hack patches things for Obsidian.