-
Describe the questionI'm trying to implement a custom Linemode in Yazi. Based on my understanding, I should be able to access functions from function Linemode:file_info()
return ui.Line("%s %s %s", self:permissions(), self:size(), self:mtime())
end Here's an example from the documentation: -- ~/.config/yazi/init.lua
function Linemode:size_and_mtime()
local time = math.floor(self._file.cha.modified or 0)
if time == 0 then
time = ""
elseif os.date("%Y", time) == os.date("%Y") then
time = os.date("%b %d %H:%M", time)
else
time = os.date("%b %d %Y", time)
end
local size = self._file:size()
return ui.Line(string.format("%s %s", size and ya.readable_size(size) or "-", time))
end But instead of rewriting the logic, I would like to call functions like Another attempt I made was this: function Linemode:file_info()
-- Get time of last modification
local time = math.floor(self._file.cha.modified or 0)
if time == 0 then
time = ""
elseif os.date("%Y", time) == os.date("%Y") then
time = os.date("%b %d %H:%M", time)
else
time = os.date("%b %d %Y", time)
end
-- Get file size or number of files in a folder
local size = self._file:size()
if size then
size = ya.readable_size(size)
else
local folder = cx.active:history(self._file.url)
size = folder and tostring(#folder.files) or ""
end
-- Get file permissions
local permissions = self._file.cha:perm() or ""
return ui.Line(string.format("%s %s %s", permissions, size, time))
end However, the permissions part doesn't seem to work properly. Additional Question:Is it possible to display folder sizes directly? While sorting folders by size is supported, it seems this feature isn't available in Validations
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
With the latest nightly version of Yazi, you can achieve this by simply: function Linemode:file_info()
return string.format("%s %s %s", self:permissions(), self:size(), self:mtime())
end |
Beta Was this translation helpful? Give feedback.
With the latest nightly version of Yazi, you can achieve this by simply: