2

I only recently discovered (yes, I'm late to the game) that TextEdit.app is adding extended attributes to any files I open in it. I had discovered this when I randomly had opened a shell script in it and it got quarantined and wouldn't run.

I quickly learned that I can remove attributes with either xattr -c file or individual attributes with xattr -d attrname file, but doing that is tedious/tiresome. I happen to like TextEdit (which I'm aware is in disfavor among pros). I have other editors for editing code, so I’m not looking for alternate editor suggestions. What I’d like to know is, is there a way to get it to stop adding extended attributes to files?

I tried defaults write com.apple.LaunchServices LSQuarantine -bool false, but it still happens.

Or maybe I'm being too fastidious? Other than the quarantine attribute, can any of the other cruft get in the way of other users on non-macOS systems, say when in a github repo or otherwise deployed to other systems?

My main concerns are first: getting a quarantine flag that was opened for a quick/simple edit, and second: edits to text files (like README.txt) that are included in a social coding repository (like github). My desire to avoid extended attributes is the same as the reason I remove .DS_Store files before I commit changes to a repo - they are system-specific and are otherwise useless (or possibly obstacles?) to others. TextEdit is for editing text. Scripts and READMEs are text files. I also use it for all sorts of other text files which I process on the command line, like fasta and fastq files. TextEdit (while it definitely lacks features other editors have) has useful features that other editors do not have or do not do well, and I've been using it since the beginning and will continue to use it despite the alternative preference or opinions of others. It has only become a problem the other day, when for some reason, I was unable to run a script that I had run and then opened in TextEdit to make a very minor change, and then found I couldn't run it again.

But perhaps I'm wrong about my main concern? Perhaps it wasn't even TextEdit that added the quarantine attribute, because I've been unable to reproduce that issue. So does TextEdit ever add the quarantine attribute, and if so, when?

I wrote an automator service I can use to remove attributes on selected files, but if there's a way to change TextEdit's behavior, that would be preferable. Otherwise, I'll probably also add an xattr command to my checkin wrapper.

5
  • What meta da a does texted it write? – mmmmmm May 22 '20 at 17:32
  • @user151019 "com.apple.TextEncoding com.apple.lastuseddate#PS com.apple.metadata:_kMDItemUserTags" – anki May 22 '20 at 18:26
  • Which one of those causes a problem? – mmmmmm May 22 '20 at 18:40
  • The attributes added vary depending on what you do to the file and whether or not they cause a problem is part of the question I asked, so you tell me. The only one I’ve encountered that caused a problem for me is the quarantine flag. But I don’t want to include this cruft in a PR on someone else’s repo. Does this stick to the file when I git push? – hepcat72 May 22 '20 at 18:49
  • I've tried vaious files now (plain, RTF, executable scripts) and only got "harmless" attributes added. Can you reproduce a scenario where a quarantine attribue gets added by TextEdit? – nohillside May 23 '20 at 12:37
3

TextEdit should not (and does not) normally add quarantine attributes to files that it saves. It's possible that MacOS is adding the quarantine for some other reason. (Where are you saving to?)

However, there are other extended attributes, which TextEdit may add during the course of normal operation in MacOS.

Normally, extended attributed don't get copied to things like github, and are simply unused by other platforms, even if present.

I also agree with bmike. If an app has a behaviour you don't like, then use another app.

3
  • Thanks. That’s reassuring. Do you know what does add the quarantine attribute? I assume Safari does, but I recall the script running initially and then inexplicably not running in my case. It was only googling the error when I learned about the quarantine attribute, and extended attributes in general. I wish I could remember the order of events, but at the time, I had no reason to be that mindful of the process I was using. – hepcat72 May 22 '20 at 21:59
  • If what you’re saying is true, then TextEdit does do what I want (or rather, doesn’t do what I don’t want to a degree I care about). I’m still curious about what applies the quarantine attribute, when, and under what circumstances. So the question is, what does “normally”, in your answer, mean? – hepcat72 May 22 '20 at 22:39
  • Normally, quarantine attributes get added to incoming files: from Safari, and possibly over network file connections. However, note that there are many other extended attributes that Text Edit DOES add. – benwiggy May 23 '20 at 12:17
-1

Yes - I think you’re being too fastidious. I would stop TextEdit from altering a file by stopping opening it in TextEdit if you’re sure that’s the culprit. We don’t have any such issue at my work across mac admins and developers, so perhaps a reproducible test case will help us help you.

I understand this may be controversial to say don’t change the app - change your process, but my answer to this dilemma is don’t have the dilemma in the first place. Embrace TE for what it is, not what you want it to be.

I would be quite surprised to not fins domething else in your workflow is better suited to fix whatever dilemma your file attributes cause you (which isn’t entirely clear to me based on your initial version of the question).

To go further, I use this quarantine bit (and all the other metadata that apps like TE attach to files) as a feature and not a bug or something to be avoided.

If TextEdit is causing you grief, I would recommend the free BBEdit and VSCode apps so you can test editors that are more powerful - both have command line integration so you can set them as your editor or open files easily and then you can also change the launch services to open files in these apps as your preference changes only using Text Edit for when you want what it does.

I use the quarantine attribute intentionally when I want to deliver something and know my recipients of a file/script chose to run the script / prevent tampering in flight, etc...

BBEdit is on the Mac app store as well if you prefer that over direct download, Code is not.

As pointed out in the comments, the true solution here is to level up handling metadata and not let metadata and filesystem attributes ruin your day.

8
  • 1
    This doesn't answer the question. I have other editors. It's fine you like this unadvertised feature, but having the option to turn this behavior off would also be a nice feature. I just don't like BBEdit. – hepcat72 May 22 '20 at 16:43
  • Also, I never described this as a bug. – hepcat72 May 22 '20 at 17:46
  • Part of me wants more downvote so I can finally get a badge for deleting a post with -4 (although I feel strongly this is the right answer for most and may see how far my - votes can go) Also, my first post (and hopefully all the edits) does answer the question. It also doesn’t have to be your answer. SE sites exist for a plurality of answers and you get to choose your answer as the asker. Everyone with reputation to vote should do so with gusto. I appreciate both the votes and comments, especially critical ones. – bmike May 22 '20 at 18:45
  • Not only does this not answer the question, I specifically said I like TextEdit, I.e. I want to use it. I had only added that because I wasn’t looking for suggestions of alternate text editing apps. In fact, I’ll edit the question to explicitly state this implied requirement. – hepcat72 May 22 '20 at 18:54
  • RE: "I would stop TextEdit from altering a file by stopping opening it in TextEdit" -- Considering both the apps you've mentioned, BBEdit and VSCode, also add extended attribute to the files they open, I guess you'd offer the same advice then and tell the OP to stop using them as well!? – user3439894 May 22 '20 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .