MacOS – How to hide/show a specific icon on Mac OS X Desktop

iconmacosterminal

I have managed to write a piece of code in .profile file in bash to hide/show all the icons from the Desktop, running from Terminal.

I need the same functionality just for 1 icon to work with after I have hidden all in the first place.

So I need something like showicon %1 command, where %1 is the name of the icon on Desktop.

Any Suggestions on how do I do it?

Best Answer

The Terminal command chflags can be used to hide and unhide files:

    chflags hidden /path/to/file.ext

or

    chflags nohidden /path/to/file.ext

You can create a simple alias called hideicon that invokes chflags hidden, and similarly for showicon to invoke the opposite command:

    alias hideicon='chflags hidden'

and

    alias showicon='chflags nohidden'

Add these to your ~/.bashrc file, and they'll load with each new instance of your shell.