Replace TextEdit as the default text editor application for opening plain text files and files with no extensions on macOS.
Run the following command in the Terminal to find the bundle identifier for your desired text editor application:
$ osascript -e 'id of app "Visual Studio Code"'
com.microsoft.VSCode
$ osascript -e 'id of app "Sublime Text"'
com.sublimetext.3
$ osascript -e 'id of app "Atom"'
com.github.atom
Run the following command in the Terminal to specify the text editor application to open the files:
// Visual Studio Code
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.microsoft.vscode;}' \
'{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.microsoft.vscode;}' \
'{LSHandlerContentType=public.data;LSHandlerRoleAll=com.microsoft.vscode;}'
// Sublime Text
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}' \
'{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.sublimetext.3;}' \
'{LSHandlerContentType=public.data;LSHandlerRoleAll=com.sublimetext.3;}'
// Atom
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.github.atom;}' \
'{LSHandlerContentType=public.unix-executable;LSHandlerRoleAll=com.github.atom;}' \
'{LSHandlerContentType=public.data;LSHandlerRoleAll=com.github.atom;}'
Finally, restart your machine.
Thank you bro 👍