.htaccess extension mapping

175 views
Skip to first unread message

MediaMouth

unread,
Mar 5, 2020, 4:55:26 PM3/5/20
to BBEdit Talk
I was hoping to set BBEdit to open .htaccess files under the custom filename extension mapping for Apache Configuration File ( downloaded from https://daringfireball.net/projects/apacheconfig/ )

The language module works great, but I haven't been able to get BBEdit to recognize the suffix "htacces" at Preferences > Languages > Custom filename extensions mapping


Gerald Davenport

unread,
Mar 5, 2020, 5:15:29 PM3/5/20
to bbe...@googlegroups.com
I may be doing it wrong, but I have Onyx displaying my hidden files in the finder and then the finder i set up .htaccess files to open with BBEdit.app through "get info" in the finder.

double click any .htaccess file and they open in BBEdit.

again, might be doing it wrong, but it works for me.

- gerald

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/650089DC-A0BB-463D-AC8D-3325C563C46B%40gmail.com.

Byers Home Page

Reviews on Google My Business  Give Us Feedback

Conserve Natural Resources. Reduce, Reuse, Recycle.

MediaMouth

unread,
Mar 5, 2020, 6:05:40 PM3/5/20
to bbe...@googlegroups.com
The solution you're describing actually addresses a different issue.
Having MacOS open .htaccess in BBEdit can be made to work exactly as you describe.

What I was getting at was the language module BBEdit uses for .htaccess files once they're open
Those are customized at Preferences > Languages > Custom filename extension mappings
I've got a few extension working there perfectly, but haven't been able to do the same for .htaccess

On Mar 5, 2020, at 2:09 PM, Gerald Davenport <ger...@thatsbyers.com> wrote:

I may be doing it wrong, but I have Onyx displaying my hidden files in the finder and then the finder i set up .htaccess files to open with BBEdit.app through "get info" in the finder.

double click any .htaccess file and they open in BBEdit.

again, might be doing it wrong, but it works for me.

- gerald

Gerald Davenport

unread,
Mar 5, 2020, 7:20:56 PM3/5/20
to bbe...@googlegroups.com
I realized that after I started fiddling with what you were talking about and may have messed something up. OOPS.

A restart might help.... Me that is. Hope you find your answer. BBEdit is pretty powerful, the reason why I love it!

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.

MediaMouth

unread,
Mar 5, 2020, 7:55:03 PM3/5/20
to bbe...@googlegroups.com
Ugh.  Sorry about that.
RE BBedit being powerful / loving it: agreed.

GP

unread,
Mar 6, 2020, 4:05:05 PM3/6/20
to BBEdit Talk
I tried this with BBEdit version 12.6.7 (I haven't upgraded yet) and the custom filename extension mapping worked with one big caveat.  The file must not have been saved by BBEdit before the custom filename extension mapping preference setting was made. Whatever file typing metadata BBEdit saved during the previous file save will override any newly added custom filename extension mapping preference. (If you have previous BBEdit saved htaccess extension files, I think you'll have to use the Language popup in an open file's window to change the file language type metadata on the next file save in order for the Apache Configuration File codeless language module to be used the next time that specific file is opened.)

As a test, I created a test file using TextEdit and saved it. Changed the default extension from rtf to htaccess and then opened it in BBEdit through a Finder open using BBEdit as the opening app and through BBEdit's File Open menu.  In both cases BBEdit used the htaccess file extension to mapping the file Apache Configuration File and use the associated codeless language module for syntax colorizing, etc..

MediaMouth

unread,
Mar 6, 2020, 9:14:02 PM3/6/20
to BBEdit Talk
Wow, that's quite a quirk of a solution.

For whatever reason, the issue seems either to have resolved itself with the latest upgrade or... who knows what.
As of right now .htaccess files are being recognized per the preferences I set up.  ¯\_(ツ)_/¯

The interesting thing about your observation is that from what I can tell there's no metadata contained by the file created by text edit that BBEdit wouldn't be getting rid of when it's opened and emptied -- it's a 0 bite file.  But maybe the OS 'knows' something about the file (i.e. external metadata).

Thanks for the insight!

GP

unread,
Mar 7, 2020, 9:01:49 AM3/7/20
to BBEdit Talk
With Terminal or a BBEdit Worksheet run the command mdls  on a file you want to examine the metadata for. For example, a BBEdit newly created and saved  Apache Configuration File language type small test file, the command:

mdls /Users/grp/Documents/BBEdit\ temp/MyTest3.htaccess

has the output:

kMDItemContentCreationDate         = 2020-03-07 04:38:59 +0000
kMDItemContentCreationDate_Ranking = 2020-03-07 00:00:00 +0000
kMDItemContentModificationDate     = 2020-03-07 04:38:59 +0000
kMDItemContentType                 = "dyn.ah62d4rv4ge80u7dbqrv0n65x"
kMDItemContentTypeTree             = (
    "dyn.ah62d4rv4ge80u7dbqrv0n65x",
    "public.item",
    "dyn.ah62d4rv4ge80u7dbqrv0n65x",
    "public.data"
)
kMDItemDateAdded                   = 2020-03-07 04:38:59 +0000
kMDItemDateAdded_Ranking           = 2020-03-07 00:00:00 +0000
kMDItemDisplayName                 = "MyTest3.htaccess"
kMDItemFSContentChangeDate         = 2020-03-07 04:38:59 +0000
kMDItemFSCreationDate              = 2020-03-07 04:38:59 +0000
kMDItemFSCreatorCode               = ""
kMDItemFSFinderFlags               = 0
kMDItemFSHasCustomIcon             = (null)
kMDItemFSInvisible                 = 0
kMDItemFSIsExtensionHidden         = 0
kMDItemFSIsStationery              = (null)
kMDItemFSLabel                     = 0
kMDItemFSName                      = "MyTest3.htaccess"
kMDItemFSNodeCount                 = (null)
kMDItemFSOwnerGroupID              = 20
kMDItemFSOwnerUserID               = 501
kMDItemFSSize                      = 22
kMDItemFSTypeCode                  = ""
kMDItemInterestingDate_Ranking     = 2020-03-07 00:00:00 +0000
kMDItemKind                        = "Document"
kMDItemLogicalSize                 = 22
kMDItemPhysicalSize                = 4096

Note: that output is on a Mac OS 10.13 system and my not be the same on other system versions.

The entries kMDItemContentType and kMDItemContentTypeTree uses Apple's Uniform Type Identification system to describe the data type and/or format of the file's content.  Since my system has no known Uniform Type Identifier associated with the htaccess file extension, a dynamic type identifier is used (the dyn domain).


On Friday, March 6, 2020 at 6:14:02 PM UTC-8, Harvey Pikelberger wrote:

[snip]

MediaMouth

unread,
Mar 7, 2020, 1:06:43 PM3/7/20
to bbe...@googlegroups.com
This is great.  Thanks for sharing.  I was working with kMD attributes years ago before I knew much about command line.  Was stuck trying to work in AppleScript (and at the time didn't really understand what Spotlight or kMDs were about), gave up, and never revisited.  Really helpful to re-discover.

Just for clarity: kMD metadata is not contained in the file. It's external data, handled by MacOS's Spotlight system, which is why it won't necessarily port and can disappear or change when the file is copied or moved to another location.

RE "Since my system has no known Uniform Type Identifier associated with the htaccess file extension, a dynamic type identifier is used (the dyn domain)" -- What's the story there?  Is that something you imposed?  I don't see have no kMDItemContentType / kMDItemTypeTree for .htaccess files on my system.

Apparently you can push your own custom types into your system -- thought I'm not yet sure to what end.

All very interesting.  Thanks again.

GP

unread,
Mar 7, 2020, 6:35:38 PM3/7/20
to BBEdit Talk
The details on the system's usage of Uniform Type Identifiers (UTI) comes from the discussion found the UTType.h file found in the MacOS SDKs. 

As to known UTIs, they come from two sources. One source is those Apple ships with the system and the other is those exported to the system by installed applications through entries in their Info.plist files. For an example of an application's UTI exports look in the BBEdit application's bundle Info.plist file UTExportedTypeDeclarations keyed array of exported type identifier information.

As to the creation of dynamic type identifiers, that too is handled by the system.  Read the discussion for some of the function APIs in the UTType.h file for some of the details on dynamic type identifier creation and handling.

As to what ends pushing/exporting "custom" types to the system accomplishes, at the simplest it is the means by which files/file types are associated with the application(s) that can read, manipulate, and/or write the file contents/types. Macs have been doing this since day one with type/creator codes - the UTI system is just a new and vastly improved version.

On Saturday, March 7, 2020 at 10:06:43 AM UTC-8, Harvey Pikelberger wrote:
[snip]
 
RE "Since my system has no known Uniform Type Identifier associated with the htaccess file extension, a dynamic type identifier is used (the dyn domain)" -- What's the story there?  Is that something you imposed?  I don't see have no kMDItemContentType / kMDItemTypeTree for .htaccess files on my system.
Reply all
Reply to author
Forward
0 new messages