R – OSX – always hide certain files


I know how to show and hide hidden files in the Terminal – but is there a way to hide certain files like .DS_STORE when showing hidden files? Make certain files super-hidden, so to speak?

Best Solution

Use chflags with the hidden option

ie: chflags hidden fileToHide to hide the file from the Finde

and chflags nohidden fileToHide to show the file

Please do keep in mind the warning in man page:

Only a limited number of utilities are chflags aware. Some of these tools include ls(1), cp(1), find(1), install(1), dump(8), and restore(8). In particular a tool which is not currently chflags aware is the pax(1) utility.

What that means is that while you won't see in the Finder or Open/Save dialog boxes, the Terminal will still see it and possibly other programs that don't respect BSD flags.