diff --git a/fix_macos_Home_and_End_keybinding.sh b/fix_macos_Home_and_End_keybinding.sh new file mode 100755 index 0000000..46a61cc --- /dev/null +++ b/fix_macos_Home_and_End_keybinding.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# This just solved a huge problem for me, so i'm putting it in a little script for future use +# https://damieng.com/blog/2015/04/24/make-home-end-keys-behave-like-windows-on-mac-os-x/ + +FILE="$HOME/Library/KeyBindings/DefaultKeyBinding.dict" + +if [[ -r "$FILE" ]]; then + echo "There is already a keybinding file at $FILE" +else + if ! [[ -d "$(dirname $FILE)" ]]; then + mkdir -p "$(dirname $FILE)" + fi + echo "Creating keybinding file at $FILE" + echo '{ + "\UF729" = moveToBeginningOfParagraph:; // home + "\UF72B" = moveToEndOfParagraph:; // end + "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home + "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end + "^\UF729" = moveToBeginningOfDocument:; // ctrl-home + "^\UF72B" = moveToEndOfDocument:; // ctrl-end + "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home + "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end +}' > $FILE + echo "You have to reboot in order for the changes to take effect" +fi