TextEdit key bindings modified in DefaultKeyBinding.dict stopped working
The problem was that I had moved the actual DefaultKeyBinding.dict file somewhere else for version-control purposes and symlinked to it.
Most apps were loading the file through the symlink, but TextEdit (and, it turns out, a couple other apps that I thought just didn't support key bindings) must do something different and didn't see it.
So, oops, lesson learned. Don't symlink your system configuration files.
I had the same problem myself with symlinking this file, but I didn't want to give in to this limitation, so I created a git pre-commit
hook to update ~/Library/KeyBindings/DefaultKeyBinding.dict whenever my version was committed.
Here is the code (for Git):
#!/bin/bash
if [[ $(git diff --cached --name-only | grep '.configurations/DefaultKeyBinding.dict' | wc -l) -eq 1 ]];
then
FILE_PATH_IN_LIBRARY=~/Library/KeyBindings/DefaultKeyBinding.dict
BASE_DIR=$(git rev-parse --show-toplevel)
FILE_PATH_IN_SCM=${BASE_DIR}/.configurations/DefaultKeyBinding.dict
NORMAL=$(tput sgr0)
BRIGHT=$(tput bold)
GREEN=$(tput setaf 2)
printf "${BRIGHT}${GREEN}The file <%s> was modified, updating %s${NORMAL}\n" $FILE_PATH_IN_SCM $FILE_PATH_IN_LIBRARY
cp $FILE_PATH_IN_SCM $FILE_PATH_IN_LIBRARY
fi
To use it all you need to do is replace FILE_PATH_IN_SCM=${BASE_DIR}/.configurations/DefaultKeyBinding.dict
with the location of the file in your Git Repository.
If you never created a git hook before (this was my first) - you need to place this code in:
<your-git-repo>/.git/hooks/pre-commit
Don't forget to run chmod +x <your-git-repo>/.git/hooks/pre-commit
to make it executable.
Afterwards every commit involving this file will show something like:
The file </Users/myuser/.scripts/.configurations/DefaultKeyBinding.dict> was modified, updating /Users/myuser/Library/KeyBindings/DefaultKeyBinding.dict