Assigning icons system-wide based on filename without extension

Solution 1:

Setting Atom icon via command line for Makefile

There is no direct way to set icons based on filename only, but one can set them via command line and then apply to all makefiles on the Mac.

Here are the steps to set Atom's icon to a specific Makefile via command line (assuming you Developer Tools are installed).

  1. Get the Atom icon file from /Applications/Atom.app/Contents/Resources/file.icns
  2. Convert the image to icon
    sips -i file.icns
  3. Extract the icon to its own resource file  /Library/Developer/CommandLineTools/usr/bin/DeRez -only icns file.icns > tmpicns.rsrc
  4. Append this resource to the file you want to icon-ize /Library/Developer/CommandLineTools/usr/bin/Rez -append tmpicns.rsrc -o Makefile
  5. Use the resource to set the icon
    /Library/Developer/CommandLineTools/usr/bin/SetFile -a C Makefile
  6. Restart your Mac

you can run mdfind -name makefile to get all the makefiles in your system and write a script to do the above on them.

enter image description here