How to associate /opt/local/bin/bash with .bat files

Arno Hautala arno at
Tue Jan 28 06:49:20 PST 2014

On Tue, Jan 28, 2014 at 8:40 AM, Clemens Lang <cal at> wrote:
> Macs (and other Unix systems) don't associate files and their
> interpreters based on the filename extension. Only windows uses this
> method.

That's not entirely true. Macs used to use File Type and Creator codes
to associate files and in those days extensions weren't required on
file names. These attributes are still visible via commands like
GetFileInfo. Their use is certainly deprecated and I wouldn't be
surprised if it isn't consulted at all in current versions of OS X.
Seems that as of 10.6 they're ignored in favor of Uniform Type

I'm fairly sure that the current mix of UTI and extension mapping is a
mess though. At least, it seemed to be the last time I looked into it.
That's another thread though.

These days, if you Get Info on a file (select the file in the Finder
and use Command-I or File > Get Info) there is a section labeled "Open
With". You can select an application from the list or explicitly
browse to some other application. When changing the selection, there's
a button to "Change All". Pressing that will prompt to associate "all
files with extension '.bat'" with the new application. Some extensions
are associated with known types, and some files are marked with UTIs,
and will instead ask if you want to associate, for example, all "text
files" instead of listing ".txt".

In your case though, you wouldn't want to associate a ".bat" or ".sh"
file with bash, you'd want to set it to be opened by "".
You can then edit the shebang line to set which shell should be used
to interpret the script, as indicated by Clemens.

arno  s  hautala    /-|   arno at

pgp b2c9d448

More information about the macports-users mailing list