I know Finder has built-in option to change default application but this is only for that extension. I want to make available my editor (MacVim) for all kind of text files. Such as .html, .xml, ... .gitignore etc., even unknown extensions like.this.
I have tried duti but looks like not working anymore.
I also tried:
$ defaults write com.apple.LaunchServices LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'
$ defaults read com.apple.LaunchServices
{
LSHandlers = (
{
LSHandlerContentType = "public.plain-text";
LSHandlerRoleAll = "org.vim.MacVim";
}
);
}
and with different UTIs like public.text
, public.utf8-plain-text
. No luck.
Any help appreciated. I don't want to see TextEdit anymore...
Well, this answer on Ask Different mentions your method to be outdated. It also points to another answer that is supposed to work on newer macOS versions (those that came after Mavericks).
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'
Notice the difference between com.apple.LaunchServices LSHandlers -array-add
in your code and com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add
in the offered solution.
EDIT
I forgot to mention that a restart is needed (linked answer does mention this though).
Also, please note (see this answer's comments) that the OP apparently needed to export all defaults with defaults read com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers > defualts.txt
, change all apps to org.vim.MacVim
via a text-editor, before re-importing them via defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers "$(cat defualts.txt)"