A question came up about setting the Git editor to a bash function, which I could not figure out. I was, however, able to set the Git editor to a bash script. As a proof of concept, here is a bash script to randomly choose an editor (nano or vim) when using Git.
I saved this file as ~/my-random-git-editor-script
#!/bin/bash
if (( RANDOM % 2 )); then
editor="nano"
else
editor="vim"
fi
exec "$editor" "$@"
and made it executable by running
chmod +x ~/my-random-git-editor-script
and finally I updated my Git config to use the script by running
git config --global core.editor "~/my-random-git-editor-script"
Leave a Reply