Hello everyone. I cannot speak for everyone, of course, but it seems there are many people, not just me, who have or had the issue that Finder shows wrong icons. For example, you have Sublime Text installed, and you have test.md
somewhere. But despite you have set “Open with” to “Xcode” for all your Markdown files (Get Info > Open with = Xcode > Change All), your test.md
will have Sublime Text icon.
There are many solutions on the internet about this issue, for example, a long discussion here or this article by Howard Oakley.
However, in practice, when I tried to understand why some icons didn’t look the way I expected, all these solutions and explanations weren’t enough. So I decided to figure it out myself, with a lot of tests and so on.
I made some observations and I want everyone to help me check them, for our common benefit. So that if one have wrong icons, he or she can understand why it happen and what to do.
Part 1. Pre-requirements
-
Update macOS and install/update Sublime Text, CotEditor, Typora, and Xcode.
-
Start up your computer in macOS Recovery and disable system integrity protection (Options > Continue > Utilites > Terminal), then reboot.
csrutil disable
(Later you can enable it back the same way, using
csrutil enable
.)reboot
-
Write down the following script to clear the icon cache, you will use it a lot:
sudo rm -rfv /Library/Caches/com.apple.iconservices.store; sudo find /private/var/folders/ \( -name com.apple.dock.iconcache -or -name com.apple.iconservices \) -exec rm -rfv {} \; ; sleep 3;sudo touch /Applications/* ; killall Dock; killall Finder
-
For convenience, disable “Show icon previews” in your test directory.
Part 2. My observations: Markdown
Create test.md
> Get Info > Open With = Sublime Text > Clear the icon cache using the script above. The icon will be changed to
test.md
> Get Info > Open With = CotEditor > Clear the icon cache using the script above. The icon will be changed to
test.md
> Get Info > Open With = Typora > Clear the icon cache using the script above. The icon will be changed to
test.md
> Get Info > Open With = TextEdit > Clear the icon cache using the script above. Note that the icon will be changed to the icon it would be if you changed “Open with” to “Xcode” instead of “TextEdit”! (I hope this sentence is clear, Englsh is not my primary language.) Here it is:
As far as I understand, this is because TextEdit doesn’t support Markdown, from the point of view of Finder, and so Finder use an icon from the most “nearest” app that do support it. Note that I don’t understand why Finder preferred Xcode over Sublime Text, CotEditor, or Typora, all of which do support Markdown as well.
Part 3. My observations: Lua
(The Lua case doesn’t tell us anything new. It simply confirms what is already written in the Markdown section.)
Create test.lua
> Get Info > Open With = Sublime Text > Clear the icon cache using the script above. The icon will be changed to
Get Info > Open With = TextEdit or Xcode > Clear the icon cache using the script above. The icon will be changed to
As far as I understand, this is because neither TextEdit nor Xcode support Markdown, from the point of view of Finder, whereas Lua is supported by Sublime Text and CotEditor, and so Finder use an icon from the most “nearest” app that do support it, which happen to be CotEditor. Note that I don’t understand why Finder preferred CotEditor over Sublime Text.
My questions
-
Does everything works the same for you?
-
Do you know whether my explanations above are correct?
-
Do you know why Finder preferred Xcode over Sublime Text, CotEditor, and Typora for Markdown; and why it preferred CotEditor over Sublime Text for Lua?