Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joshkautz/59a9778db92467bd557460a979552788 to your computer and use it in GitHub Desktop.
Save joshkautz/59a9778db92467bd557460a979552788 to your computer and use it in GitHub Desktop.
Replace TextEdit as the default text editor

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.

Copy link

ghost commented Jan 18, 2021

Thank you bro 👍

@bgrand-ch
Copy link

Thanks a lot!

@hirasso
Copy link

hirasso commented Feb 2, 2022

Nice!! Thanks

@kameyama
Copy link

Thanks!

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