fix!: remove the vnd. prefix from mimetype to solve differences introduced in the newest version of file(1) 5.46 (#1995)

This commit is contained in:
三咲雅 · Misaki Masa 2024-12-05 22:07:40 +08:00 committed by sxyazi
parent c7d9265d25
commit fbf9b3d1ed
No known key found for this signature in database
7 changed files with 479 additions and 254 deletions

View file

@ -31,7 +31,7 @@ function dump(map)
end
function save(typ, files, exts)
local p = string.format("../../yazi-config/preset/theme+%s.toml", typ)
local p = string.format("../../yazi-config/preset/theme-%s.toml", typ)
local s = io.open(p, "r"):read("*a")
s = s:gsub("files = %[\n(.-)\n%]", string.format("files = [\n%s]", files))
s = s:gsub("exts = %[\n(.-)\n%]", string.format("exts = [\n%s]", exts))

View file

@ -1,229 +0,0 @@
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
# vim:fileencoding=utf-8:foldmethod=marker
# : Flavor {{{
[flavor]
dark = ""
light = ""
# : }}}
# : Manager {{{
[manager]
cwd = { fg = "cyan" }
# Hovered
hovered = { reversed = true }
preview_hovered = { underline = true }
# Find
find_keyword = { fg = "yellow", bold = true, italic = true, underline = true }
find_position = { fg = "magenta", bg = "reset", bold = true, italic = true }
# Marker
marker_copied = { fg = "lightgreen", bg = "lightgreen" }
marker_cut = { fg = "lightred", bg = "lightred" }
marker_marked = { fg = "lightcyan", bg = "lightcyan" }
marker_selected = { fg = "lightyellow", bg = "lightyellow" }
# Tab
tab_active = { reversed = true }
tab_inactive = {}
tab_width = 1
# Count
count_copied = { fg = "white", bg = "green" }
count_cut = { fg = "white", bg = "red" }
count_selected = { fg = "white", bg = "yellow" }
# Border
border_symbol = "│"
border_style = { fg = "gray" }
# Highlighting
syntect_theme = ""
# : }}}
# : Mode {{{
[mode]
normal_main = { bg = "blue", bold = true }
normal_alt = { fg = "blue", bg = "gray" }
# Select mode
select_main = { bg = "red", bold = true }
select_alt = { fg = "red", bg = "gray" }
# Unset mode
unset_main = { bg = "red", bold = true }
unset_alt = { fg = "red", bg = "gray" }
# : }}}
# : Status bar {{{
[status]
separator_open = ""
separator_close = ""
# Progress
progress_label = { bold = true }
progress_normal = { fg = "blue", bg = "black" }
progress_error = { fg = "red", bg = "black" }
# Permissions
perm_sep = { fg = "darkgray" }
perm_type = { fg = "green" }
perm_read = { fg = "yellow" }
perm_write = { fg = "red" }
perm_exec = { fg = "cyan" }
# : }}}
# : Pick {{{
[pick]
border = { fg = "blue" }
active = { fg = "magenta", bold = true }
inactive = {}
# : }}}
# : Input {{{
[input]
border = { fg = "blue" }
title = {}
value = {}
selected = { reversed = true }
# : }}}
# : Confirm {{{
[confirm]
border = { fg = "blue" }
title = { fg = "blue" }
content = {}
list = {}
btn_yes = { reversed = true }
btn_no = {}
btn_labels = [ " [Y]es ", " (N)o " ]
# : }}}
# : Completion {{{
[completion]
border = { fg = "blue" }
active = { reversed = true }
inactive = {}
# Icons
icon_file = ""
icon_folder = ""
icon_command = ""
# : }}}
# : Tasks {{{
[tasks]
border = { fg = "blue" }
title = {}
hovered = { fg = "magenta", underline = true }
# : }}}
# : Which {{{
[which]
cols = 3
mask = { bg = "black" }
cand = { fg = "lightcyan" }
rest = { fg = "darkgray" }
desc = { fg = "lightmagenta" }
separator = "  "
separator_style = { fg = "darkgray" }
# : }}}
# : Help {{{
[help]
on = { fg = "cyan" }
run = { fg = "magenta" }
desc = {}
hovered = { reversed = true, bold = true }
footer = { fg = "black", bg = "white" }
# : }}}
# : Notify {{{
[notify]
title_info = { fg = "green" }
title_warn = { fg = "yellow" }
title_error = { fg = "red" }
# Icons
icon_info = ""
icon_warn = ""
icon_error = ""
# : }}}
# : File-specific styles {{{
[filetype]
rules = [
# Images
{ mime = "image/*", fg = "yellow" },
# Media
{ mime = "{audio,video}/*", fg = "magenta" },
# Archives
{ mime = "application/{,g}zip", fg = "red" },
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar}", fg = "red" },
# Documents
{ mime = "application/{pdf,doc,rtf,vnd.*}", fg = "cyan" },
# Empty files
# { mime = "inode/empty", fg = "red" },
# Special files
{ name = "*", is = "orphan", bg = "red" },
{ name = "*", is = "exec" , fg = "green" },
# Dummy files
{ name = "*", is = "dummy", bg = "red" },
{ name = "*/", is = "dummy", bg = "red" },
# Fallback
# { name = "*", fg = "white" },
{ name = "*/", fg = "blue" }
]
# : }}}

View file

@ -1,10 +1,236 @@
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
# If the user's terminal is in dark mode, Yazi will load `theme-dark.toml` on startup; otherwise, `theme-light.toml`.
# You can override any parts of them that are not related to the dark/light mode in your own `theme.toml`.
# If you want to dynamically override their content based on dark/light mode, you can specify two different flavors
# for dark and light modes under `[flavor]`, and do so in those flavors instead.
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
# vim:fileencoding=utf-8:foldmethod=marker
# : Flavor {{{
[flavor]
dark = ""
light = ""
# : }}}
# : Manager {{{
[manager]
cwd = { fg = "cyan" }
# Hovered
hovered = { reversed = true }
preview_hovered = { underline = true }
# Find
find_keyword = { fg = "yellow", bold = true, italic = true, underline = true }
find_position = { fg = "magenta", bg = "reset", bold = true, italic = true }
# Marker
marker_copied = { fg = "lightgreen", bg = "lightgreen" }
marker_cut = { fg = "lightred", bg = "lightred" }
marker_marked = { fg = "lightcyan", bg = "lightcyan" }
marker_selected = { fg = "lightyellow", bg = "lightyellow" }
# Tab
tab_active = { reversed = true }
tab_inactive = {}
tab_width = 1
# Count
count_copied = { fg = "white", bg = "green" }
count_cut = { fg = "white", bg = "red" }
count_selected = { fg = "white", bg = "yellow" }
# Border
border_symbol = "│"
border_style = { fg = "gray" }
# Highlighting
syntect_theme = ""
# : }}}
# : Mode {{{
[mode]
normal_main = { bg = "blue", bold = true }
normal_alt = { fg = "blue", bg = "gray" }
# Select mode
select_main = { bg = "red", bold = true }
select_alt = { fg = "red", bg = "gray" }
# Unset mode
unset_main = { bg = "red", bold = true }
unset_alt = { fg = "red", bg = "gray" }
# : }}}
# : Status bar {{{
[status]
separator_open = ""
separator_close = ""
# Progress
progress_label = { bold = true }
progress_normal = { fg = "blue", bg = "black" }
progress_error = { fg = "red", bg = "black" }
# Permissions
perm_sep = { fg = "darkgray" }
perm_type = { fg = "green" }
perm_read = { fg = "yellow" }
perm_write = { fg = "red" }
perm_exec = { fg = "cyan" }
# : }}}
# : Pick {{{
[pick]
border = { fg = "blue" }
active = { fg = "magenta", bold = true }
inactive = {}
# : }}}
# : Input {{{
[input]
border = { fg = "blue" }
title = {}
value = {}
selected = { reversed = true }
# : }}}
# : Confirm {{{
[confirm]
border = { fg = "blue" }
title = { fg = "blue" }
content = {}
list = {}
btn_yes = { reversed = true }
btn_no = {}
btn_labels = [ " [Y]es ", " (N)o " ]
# : }}}
# : Completion {{{
[completion]
border = { fg = "blue" }
active = { reversed = true }
inactive = {}
# Icons
icon_file = ""
icon_folder = ""
icon_command = ""
# : }}}
# : Tasks {{{
[tasks]
border = { fg = "blue" }
title = {}
hovered = { fg = "magenta", underline = true }
# : }}}
# : Which {{{
[which]
cols = 3
mask = { bg = "black" }
cand = { fg = "lightcyan" }
rest = { fg = "darkgray" }
desc = { fg = "lightmagenta" }
separator = "  "
separator_style = { fg = "darkgray" }
# : }}}
# : Help {{{
[help]
on = { fg = "cyan" }
run = { fg = "magenta" }
desc = {}
hovered = { reversed = true, bold = true }
footer = { fg = "black", bg = "white" }
# : }}}
# : Notify {{{
[notify]
title_info = { fg = "green" }
title_warn = { fg = "yellow" }
title_error = { fg = "red" }
# Icons
icon_info = ""
icon_warn = ""
icon_error = ""
# : }}}
# : File-specific styles {{{
[filetype]
rules = [
# Images
{ mime = "image/*", fg = "yellow" },
# Media
{ mime = "{audio,video}/*", fg = "magenta" },
# Archives
{ mime = "application/{,g}zip", fg = "red" },
{ mime = "application/{tar,bzip*,7z*,xz,rar}", fg = "red" },
# Documents
{ mime = "application/{pdf,doc,rtf}", fg = "cyan" },
# Empty files
# { mime = "inode/empty", fg = "red" },
# Special files
{ name = "*", is = "orphan", bg = "red" },
{ name = "*", is = "exec" , fg = "green" },
# Dummy files
{ name = "*", is = "dummy", bg = "red" },
{ name = "*/", is = "dummy", bg = "red" },
# Fallback
# { name = "*", fg = "white" },
{ name = "*/", fg = "blue" }
]
# : }}}
# : Icons {{{
[icon]

View file

@ -1,10 +1,236 @@
# If the user's terminal is in dark mode, Yazi will use the content from `theme-base.toml` + `theme+dark.toml` as the default theme;
# if it's in light mode, use `theme-base.toml` + `theme+light.toml` instead.
# Users can always override and adjust the default theme in their own `theme.toml` configuration file.
# If the user's terminal is in dark mode, Yazi will load `theme-dark.toml` on startup; otherwise, `theme-light.toml`.
# You can override any parts of them that are not related to the dark/light mode in your own `theme.toml`.
# If you want to dynamically override their content based on dark/light mode, you can specify two different flavors
# for dark and light modes under `[flavor]`, and do so in those flavors instead.
"$schema" = "https://yazi-rs.github.io/schemas/theme.json"
# vim:fileencoding=utf-8:foldmethod=marker
# : Flavor {{{
[flavor]
dark = ""
light = ""
# : }}}
# : Manager {{{
[manager]
cwd = { fg = "cyan" }
# Hovered
hovered = { reversed = true }
preview_hovered = { underline = true }
# Find
find_keyword = { fg = "yellow", bold = true, italic = true, underline = true }
find_position = { fg = "magenta", bg = "reset", bold = true, italic = true }
# Marker
marker_copied = { fg = "lightgreen", bg = "lightgreen" }
marker_cut = { fg = "lightred", bg = "lightred" }
marker_marked = { fg = "lightcyan", bg = "lightcyan" }
marker_selected = { fg = "lightyellow", bg = "lightyellow" }
# Tab
tab_active = { reversed = true }
tab_inactive = {}
tab_width = 1
# Count
count_copied = { fg = "white", bg = "green" }
count_cut = { fg = "white", bg = "red" }
count_selected = { fg = "white", bg = "yellow" }
# Border
border_symbol = "│"
border_style = { fg = "gray" }
# Highlighting
syntect_theme = ""
# : }}}
# : Mode {{{
[mode]
normal_main = { bg = "blue", bold = true }
normal_alt = { fg = "blue", bg = "gray" }
# Select mode
select_main = { bg = "red", bold = true }
select_alt = { fg = "red", bg = "gray" }
# Unset mode
unset_main = { bg = "red", bold = true }
unset_alt = { fg = "red", bg = "gray" }
# : }}}
# : Status bar {{{
[status]
separator_open = ""
separator_close = ""
# Progress
progress_label = { bold = true }
progress_normal = { fg = "blue", bg = "black" }
progress_error = { fg = "red", bg = "black" }
# Permissions
perm_sep = { fg = "darkgray" }
perm_type = { fg = "green" }
perm_read = { fg = "yellow" }
perm_write = { fg = "red" }
perm_exec = { fg = "cyan" }
# : }}}
# : Pick {{{
[pick]
border = { fg = "blue" }
active = { fg = "magenta", bold = true }
inactive = {}
# : }}}
# : Input {{{
[input]
border = { fg = "blue" }
title = {}
value = {}
selected = { reversed = true }
# : }}}
# : Confirm {{{
[confirm]
border = { fg = "blue" }
title = { fg = "blue" }
content = {}
list = {}
btn_yes = { reversed = true }
btn_no = {}
btn_labels = [ " [Y]es ", " (N)o " ]
# : }}}
# : Completion {{{
[completion]
border = { fg = "blue" }
active = { reversed = true }
inactive = {}
# Icons
icon_file = ""
icon_folder = ""
icon_command = ""
# : }}}
# : Tasks {{{
[tasks]
border = { fg = "blue" }
title = {}
hovered = { fg = "magenta", underline = true }
# : }}}
# : Which {{{
[which]
cols = 3
mask = { bg = "black" }
cand = { fg = "lightcyan" }
rest = { fg = "darkgray" }
desc = { fg = "lightmagenta" }
separator = "  "
separator_style = { fg = "darkgray" }
# : }}}
# : Help {{{
[help]
on = { fg = "cyan" }
run = { fg = "magenta" }
desc = {}
hovered = { reversed = true, bold = true }
footer = { fg = "black", bg = "white" }
# : }}}
# : Notify {{{
[notify]
title_info = { fg = "green" }
title_warn = { fg = "yellow" }
title_error = { fg = "red" }
# Icons
icon_info = ""
icon_warn = ""
icon_error = ""
# : }}}
# : File-specific styles {{{
[filetype]
rules = [
# Images
{ mime = "image/*", fg = "yellow" },
# Media
{ mime = "{audio,video}/*", fg = "magenta" },
# Archives
{ mime = "application/{,g}zip", fg = "red" },
{ mime = "application/{tar,bzip*,7z*,xz,rar}", fg = "red" },
# Documents
{ mime = "application/{pdf,doc,rtf}", fg = "cyan" },
# Empty files
# { mime = "inode/empty", fg = "red" },
# Special files
{ name = "*", is = "orphan", bg = "red" },
{ name = "*", is = "exec" , fg = "green" },
# Dummy files
{ name = "*", is = "dummy", bg = "red" },
{ name = "*/", is = "dummy", bg = "red" },
# Fallback
# { name = "*", fg = "white" },
{ name = "*/", fg = "blue" }
]
# : }}}
# : Icons {{{
[icon]

View file

@ -68,7 +68,7 @@ rules = [
{ mime = "{audio,video}/*", use = [ "play", "reveal" ] },
# Archive
{ mime = "application/{,g}zip", use = [ "extract", "reveal" ] },
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar}", use = [ "extract", "reveal" ] },
{ mime = "application/{tar,bzip*,7z*,xz,rar}", use = [ "extract", "reveal" ] },
# JSON
{ mime = "application/{json,ndjson}", use = [ "edit", "reveal" ] },
{ mime = "*/javascript", use = [ "edit", "reveal" ] },
@ -115,7 +115,7 @@ preloaders = [
{ mime = "application/pdf", run = "pdf" },
# Font
{ mime = "font/*", run = "font" },
{ mime = "application/vnd.ms-opentype", run = "font" },
{ mime = "application/ms-opentype", run = "font" },
]
previewers = [
{ name = "*/", run = "folder", sync = true },
@ -133,10 +133,10 @@ previewers = [
{ mime = "application/pdf", run = "pdf" },
# Archive
{ mime = "application/{,g}zip", run = "archive" },
{ mime = "application/{tar,bzip*,7z-compressed,xz,rar,iso9660-image}", run = "archive" },
{ mime = "application/{tar,bzip*,7z*,xz,rar,iso9660-image}", run = "archive" },
# Font
{ mime = "font/*", run = "font" },
{ mime = "application/vnd.ms-opentype", run = "font" },
{ mime = "application/ms-opentype", run = "font" },
# Empty file
{ mime = "inode/empty", run = "empty" },
# Fallback

View file

@ -43,22 +43,24 @@ macro_rules! theme_preset {
($name:literal) => {{
#[cfg(debug_assertions)]
{
let append = std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/preset/theme+",
$name,
".toml"
))
.expect(concat!("Failed to read 'yazi-config/preset/theme+", $name, ".toml'"));
std::borrow::Cow::from(format!("{}\n{append}", &$crate::config_preset!("theme-base")))
std::borrow::Cow::from(
std::fs::read_to_string(concat!(
env!("CARGO_MANIFEST_DIR"),
"/preset/theme-",
$name,
".toml"
))
.expect(concat!("Failed to read 'yazi-config/preset/theme-", $name, ".toml'")),
)
}
#[cfg(not(debug_assertions))]
{
std::borrow::Cow::from(concat!(
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme-base.toml")),
"\n",
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/preset/theme+", $name, ".toml"))
))
std::borrow::Cow::from(include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/preset/theme-",
$name,
".toml"
)))
}
}};
}

View file

@ -5,7 +5,7 @@ local M = {}
local function match_mimetype(s)
local type, sub = s:match("^([-a-z]+/)([+-.a-zA-Z0-9]+)%s*$")
if type and sub and SUPPORTED_TYPES:find(type, 1, true) then
return type:gsub("^x%-", "", 1) .. sub:gsub("^x%-", "", 1)
return type:gsub("^x%-", "", 1) .. sub:gsub("^x%-", "", 1):gsub("^vnd%.", "", 1)
end
end