You might know that prefixing a file or a directory with . makes it ‘hidden’ in unix-based systems – i.e. they won’t show up when you run ls and they won’t show up in your file browser (e.g. Finder).

However, did you know that MacOS lets you hide any directory in Finder – even if it’s not .hidden – using chflags?

$ chflags hidden dir1 dir2 dir3

I use the above to hide directories in my home directory, that I can’t remove (MacOS regenerates them automatically):

chflags hidden Applications Movies Music Pictures Public

This saves me from context switching and searching for the directory or file that I want whenever I open my home directory.

Note: chflags hidden doesn’t remove the directories, only hides them in Finder. They are still visible with ls.