mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-21 23:01: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 = {}
|
||||
|
||||
function M:peek()
|
||||
local output, code = Command("file")
|
||||
:args({
|
||||
"-bL",
|
||||
tostring(self.file.url),
|
||||
})
|
||||
:stdout(Command.PIPED)
|
||||
:output()
|
||||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||
local output, code = Command(cmd):args({ "-bL", tostring(self.file.url) }):stdout(Command.PIPED):output()
|
||||
|
||||
local p
|
||||
if output then
|
||||
|
|
@ -15,7 +10,7 @@ function M:peek()
|
|||
else
|
||||
p = ui.Paragraph(self.area, {
|
||||
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
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ function M:preload()
|
|||
local cmd = os.getenv("YAZI_FILE_ONE") or "file"
|
||||
local child, code = Command(cmd):args({ "-bL", "--mime-type" }):args(urls):stdout(Command.PIPED):spawn()
|
||||
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
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue