I just never want TextEdit to be opened, and instead set sublime as the default editor for all plain-text
files. So not only files with *.txt
extension.
For older versions than Big Sur the following command always has worked for me:
defaults write com.apple.LaunchServices/com.apple.launchservices.secure \
LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
From this answer: https://apple.stackexchange.com/a/123834/405588
But on Big Sur this doesn't work anymore. Even after restarting MacOS text files still open with TextEdit.
edit: apparently after running the command above double clicking dot files like ~/.bashrc
do open in Sublime. But when running open ~/.bashrc
from Terminal it still opens the file in TextEdit...
sublime ~/.bash
instead ofopen ~/.bash
public.plain-text
. Rather they are now designated aspublic.data
. See this answer