mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
feat: add support for YAZI_FILE_ONE to the built-in file previewer (#846)
This commit is contained in:
parent
f6f2c30709
commit
e903320d95
2 changed files with 4 additions and 9 deletions
|
|
@ -1,13 +1,8 @@
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
function M:peek()
|
function M:peek()
|
||||||
local output, code = Command("file")
|
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||||
:args({
|
local output, code = Command(cmd):args({ "-bL", tostring(self.file.url) }):stdout(Command.PIPED):output()
|
||||||
"-bL",
|
|
||||||
tostring(self.file.url),
|
|
||||||
})
|
|
||||||
:stdout(Command.PIPED)
|
|
||||||
:output()
|
|
||||||
|
|
||||||
local p
|
local p
|
||||||
if output then
|
if output then
|
||||||
|
|
@ -15,7 +10,7 @@ function M:peek()
|
||||||
else
|
else
|
||||||
p = ui.Paragraph(self.area, {
|
p = ui.Paragraph(self.area, {
|
||||||
ui.Line {
|
ui.Line {
|
||||||
ui.Span("Failed to spawn `file` command, error code: " .. tostring(code)),
|
ui.Span(string.format("Spawn `%s` command returns %s", cmd, code)),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function M:preload()
|
||||||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||||
local child, code = Command(cmd):args({ "-bL", "--mime-type" }):args(urls):stdout(Command.PIPED):spawn()
|
local child, code = Command(cmd):args({ "-bL", "--mime-type" }):args(urls):stdout(Command.PIPED):spawn()
|
||||||
if not child then
|
if not child then
|
||||||
ya.err(string.format("spawn `%s` command returns %s", cmd, code))
|
ya.err(string.format("Spawn `%s` command returns %s", cmd, code))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue