I hope this is not a repeat question—searching mostly turned up various versions of people having the opposite problem.
Is there a way to manually open a file as read-only?
The use case would be a file that I generally want write access to, but on a particular occasion want to be very confident I won't accidentally modify. For example, a shared document that I sometimes need to edit but currently only want to view. As a compulsive/instinctive saver, this would be a useful way to protect myself from myself.
I'm running Big Sur 11.2.1 on an early-2014 Macbook Air.
- Get info, change my permissions to read-only, open; once finished, close, change my permissions back: This is a hassle.
- Open, immediately Save As: Ideally I want to lock myself out before I even have a chance to break the file.
- Duplicate the file, open the 'scratch' version; generally, delete the scratch version once I'm done: Still sort of a hassle, but the best Plan B I can think of.
- I imagine this can be done from Terminal, and am happy to learn how, but any sort of GUI method would be best.
- I imagine there's a way to create a service for this? Not sure where to start.
f=/path/to/your/file; chmod -w "$f"; open -Wn "$f"; chmod +w "$f"maybe, but it would require some more logic to cover all cases (e.g. files which are read-only already, files which
opendoesn't know how to open etc).
chflags uchg filenameand
chflags nouchg filename. The immutable bit essentially sets the file to be not subject to change, thus it can't be edited or deleted. An attempt to edit such a file will result in a pop-up which asks if the user wants to Duplicate and open, Cancel or Unlock. The uchg flag is the same mechanism used in locking and unlocking files through the Get Info command.