MIME Types for Nushell
MIME types, also known as media or content types, are used to identify data formats. Since Nushell is not officially recognized by the Internet Assigned Numbers Authority (IANA), all Nushell MIME types are prefixed with "x-" to indicate their unofficial status. Despite this, some tools still rely on MIME types to identify data formats.
The three MIME types we define and recommend for consistent use are:
application/x-nuscript: This type is used for Nushell scripts and is similar toapplication/x-shellscriptfor Bash scripts. The "application" type is used because these scripts can be executable if the correct shebang is included.text/x-nushell: This is an alias forapplication/x-nuscriptbut emphasizes that the script is human-readable, similar totext/x-python.application/x-nuon: This type is used for the NUON data format.
How Nushell uses these types
Nushell records the content type of some pipeline data in its metadata (the content_type field):
opensetsapplication/x-nuscriptfor.nufiles. Whenopenparses a file with afromcommand (for example a.nuon,.jsonor.mdfile), the parsed value has no content type. Withopen --raw, the file's content type is kept.to nuonsetsapplication/x-nuon. Othertocommands set their own types, e.g.to jsonsetsapplication/json.config nu --docandview source(for a custom command) setapplication/x-nuscript.
{a: 1} | to nuon | metadata | get content_type
# => application/x-nuon
{a: 1} | save --force data.nuon
open --raw data.nuon | metadata | get content_type
# => application/x-nuon
open data.nuon | metadata | get content_type? | describe
# => nothingThe HTTP commands use these types too:
http post,http putandhttp patchsend the content type from the metadata as theContent-Typeheader when--content-typeis not given. So{a: 1} | to nuon | http post $urlsendsContent-Type: application/x-nuon.http get(like the otherhttpcommands) parses a response with thefromcommand that matches the subtype of its content type, ignoring anx-prefix. A response withContent-Type: application/x-nuonis therefore parsed withfrom nuon.
text/x-nushell is not set or recognized by Nushell itself.