brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: chflags hidden hides a file from Finder without renaming it

Finder
~/tips/tip-macos-chflags-hidden

chflags hidden ~/Desktop/scratch

Hides a file or folder from Finder and open dialogs while keeping its name.

On a Mac you don’t need a dot in front of a name to make a file invisible. There’s a separate hidden flag that Finder respects, and I like it for the odd helper file or folder that has to sit in a visible place but that I never want to click on.

The tool is chflags. Set the flag and the item disappears from Finder windows and the Desktop. The name stays exactly as it was, so scripts and apps that point at it keep working.

chflags hidden ~/Desktop/scratch
chflags nohidden ~/Desktop/scratch

The no prefix turns any flag off again. To see which flags a file has, add -O to a long listing. A hidden item shows the word hidden in an extra column:

ls -lO ~/Desktop

A classic example runs the other way round. Your Library folder carries this flag, and chflags nohidden ~/Library makes it show up in your home folder again. If you want a whole folder tree hidden or visible, -R applies the change recursively.

My caveat: this is tidiness, not privacy. ls in Terminal still lists the file, anyone with access can still open it, and the flag is a Mac thing. Copy the file to a Linux box or a share on my Unraid server and it shows up like any other file. For anything that actually needs protecting, use permissions or an encrypted disk image.

Further reading: chflags man page (SS64), ls man page for macOS (SS64)

More Finder tips Option-Command-Y Quick Actions in the Finder preview pane rotate images and make PDFs Shift-Command-P show or hide the Preview pane Command-Up Arrow open the enclosing folder click the Trash in the Dock All Finder tips (37) All topics

Link