Skip to content

Instantly share code, notes, and snippets.

@piotrkubisa
Created October 24, 2015 18:04
Show Gist options
  • Save piotrkubisa/723d97b028804cb96c80 to your computer and use it in GitHub Desktop.
Save piotrkubisa/723d97b028804cb96c80 to your computer and use it in GitHub Desktop.
Set windows-like page-up, page-down, home, end key bindings globally on OS X like a sir (using just one script).
#!/usr/bin/env
cd "$HOME/Library/"
mkdir -p "KeyBindings"
cd KeyBindings
file="DefaultKeyBinding.dict"
if [ -e $file ]; then
echo "Error: File already exists! In aware of conflicts please review insertion manually."
echo "Put the following rules in `pwd`/$file"
cat <<EOT
{
/* home */
"\\UF729" = "moveToBeginningOfLine:";
"$\\UF729" = "moveToBeginningOfLineAndModifySelection:";
/* end */
"\\UF72B" = "moveToEndOfLine:";
"$\\UF72B" = "moveToEndOfLineAndModifySelection:";
/* page up/down */
"\\UF72C" = "pageUp:";
"\\UF72D" = "pageDown:";
}
EOT
else
cat > $file <<EOT
{
/* home */
"\\UF729" = "moveToBeginningOfLine:";
"$\\UF729" = "moveToBeginningOfLineAndModifySelection:";
/* end */
"\\UF72B" = "moveToEndOfLine:";
"$\\UF72B" = "moveToEndOfLineAndModifySelection:";
/* page up/down */
"\\UF72C" = "pageUp:";
"\\UF72D" = "pageDown:";
}
EOT
fi
@piotrkubisa
Copy link
Author

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