File types in settings.json
Your own kinds of file are fileTypes in settings.json: a list,
checked in its order, before the kinds that ship. The File types screen writes it; you can write it
too, or copy it to another Mac.
"fileTypes": [
{
"type": "Camera raw",
"match": ["ext:cr3, nef, arw, raf, orf, rw2, dng", "*.raw"],
"open": { "verb": "app", "path": "/System/Applications/Preview.app" },
"view": { "verb": "smart-view", "with": "image" },
"altView": { "verb": "command", "command": "rawinfo {path}", "in": "external terminal" }
},
{ "type": ".conf", "match": ["ext:conf"], "language": "INI" }
]
The kinds that ship are not in the file, so a new version’s arrive without you changing anything. Like every setting, the list is read when the application starts.
A kind of file
- type
- Its name. Required.
- match
- Its rules, at least one. A file is this kind if any of them matches.
- open · view · altView · edit · altEdit
- What Enter, F3, ⇧F3, F4 and ⇧F4 do with it. A key left out passes on to the next kind that matches.
- language
- What the text viewer and the editor color it as: a language’s name or another name it goes by,
case aside, or
nonefor no coloring. Left out, the file’s name decides, then its start. A name no language answers to is kept, and passes the question on.
Rules
| Written | Matches |
|---|---|
ext:jpg, jpeg |
A name ending in any of these, separated by commas; a leading dot and the case do not matter |
*.jpg — no prefix |
The whole name, as a wildcard; several separated by ; |
re:^IMG_\\d+ |
A regular expression found anywhere in the name, case aside. A backslash is doubled, as JSON needs |
group:image |
What macOS says the name is: image, movie, audio, archive, source-code, plain-text, executable, application-bundle or folder |
sniff:json |
What the first 4 KB say: text, binary, script, xml, json, archive, executable or mach-o |
is:directory · is:executable · is:archive-part |
A folder · a file with permission to be run · a part of a split archive |
Each is described under Rules, by the name the screen gives it.
What a key does
Each key is a verb, and whatever that verb needs. The screen’s name for each is beside it.
verb |
On the screen | Needs |
|---|---|---|
nothing |
Do nothing | |
descend |
Go inside | |
system |
Open with system default | |
choose |
Ask: open or look inside | A small menu for a folder that is also a thing to run, such as an application; a file simply opens |
app |
Open with app | path: the app, in full or just its name (TextEdit) |
ask |
Ask which app | |
smart-view |
View here | with: a viewer — or leave it out for the one made for the file |
text-viewer |
View as text or hex | |
smart-edit |
Edit here | with: an editor — or leave it out for the one made for the file |
internal-editor |
Edit as text | |
system-editor |
Edit with system default | |
menu |
Show menu | |
run |
Run | Running a file says what runs and when it asks |
saved-search |
Run the search in it | |
search-form |
Open the search form | |
command |
Run command | command, and in — below |
- Viewers for
with image,markdown,notebook,structured-data(JSON),yaml,property-list,xml,table,diff,certificate,executable,font,document,html,video,audio— each described under File types.- Editors for
with json,yaml,xml,table.
A viewer or an editor named here is given the file whatever the file is called.
Commands
"verb": "command" runs command on the file, with the
user menu’s placeholders — {path} is the file. in
says where:
in |
Runs it |
|---|---|
external terminal |
In your own terminal app, in the active pane’s folder — see Your own terminal |
terminal |
In the built-in terminal, as if typed on the command line |
background |
In the background. Not supported yet: the key says so and runs nothing |
Leave in out and it is background, so always write it. The screen offers external terminal, and
background as its In background box.
Mistakes
A mistake costs what it is in, and nothing around it; the log says what was left out.
- A kind with no
type, nomatch, or no rule that can be used is left out. The others still work. - A rule that cannot be read — a group this version does not know, an expression that cannot be used — is dropped from its kind.
- A key that cannot be read — a verb that is not one of these,
appwith nopath,commandwith nocommand— is left out of its kind, so that key passes on.
The settings schema has every word an editor can check.