-
After updating to ac4fd9f, using the following (the first part for size + modification time) in -- linemode - size + modification time
local old_linemode = Folder.linemode
function Folder:linemode(area, _files)
if cx.active.conf.linemode ~= "custom" then
return old_linemode(self, area)
end
local lines = {}
local year = os.date("%Y")
for _, f in ipairs(self:by_kind(self.CURRENT).window) do
local time = f.cha.modified // 1
if time and os.date("%Y", time) ~= year then
time = os.date("%b. %d %Y", time)
else
time = time and os.date("%b %d %H:%M", time) or ""
end
local size = f:size()
lines[#lines + 1] = ui.Line({
ui.Span(" "),
ui.Span(size and ya.readable_size(size):gsub(" ", "") or "-"),
ui.Span(" "),
ui.Span(time),
ui.Span(" "),
})
end
return ui.Paragraph(area, lines):align(ui.Paragraph.RIGHT)
end
-- ownership in status bar
-- https://yazi-rs.github.io/docs/tips#user-group-in-status
function Status:owner()
local h = cx.active.current.hovered
if h == nil or ya.target_family() ~= "unix" then
return ui.Line({})
end
return ui.Line({
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"),
ui.Span(":"),
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
ui.Span(" "),
})
end
function Status:render(area)
self.area = area
local left = ui.Line({ self:mode(), self:size(), self:name() })
local right = ui.Line({ self:owner(), self:permissions(), self:percentage(), self:position() })
return {
ui.Paragraph(area, { left }),
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
table.unpack(Progress:render(area, right:width())),
}
end results in the following error: % y
Error: Lua runtime failed
Caused by:
runtime error: [string "init.lua"]:2: attempt to index a nil value (global 'Folder')
stack traceback:
[C]: in metamethod 'index'
[string "init.lua"]:2: in main chunk I guess this is because Any guidance on how to migrate the config is appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Linemode has been simplified, and you can now directly extend a new function Linemode:custom()
local year = os.date("%Y")
local time = (self._file.cha.modified or 0) // 1
if time > 0 and os.date("%Y", time) == year then
time = os.date("%b %d %H:%M", time)
else
time = time and os.date("%b %d %Y", time) or ""
end
local size = self._file:size()
return ui.Line(string.format(" %s %s ", size and ya.readable_size(size):gsub(" ", "") or "-", time))
end And make sure you have: [manager]
linemode = "custom" in your As for the status bar, add the following to your Status:children_add(function()
local h = cx.active.current.hovered
if not h or not ya.user_name then
return ui.Line {}
end
return ui.Line {
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("magenta"),
ui.Span(":"),
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
ui.Span(" "),
}
end, 500, Status.RIGHT) |
Beta Was this translation helpful? Give feedback.
-
I figured the ownership in status bar part, feel free to improve it: function Status:owner()
local h = self._tab.current.hovered
if not h then
return ui.Line({})
end
return ui.Line({
ui.Span(ya.user_name(h.cha.uid) or tostring(h.cha.uid)):fg("green"),
ui.Span(":"),
ui.Span(ya.group_name(h.cha.gid) or tostring(h.cha.gid)):fg("magenta"),
ui.Span(" "),
})
end
function Status:render()
local left = self:children_render(self.LEFT)
local right = ui.Line({ self:owner(), self:children_render(self.RIGHT) })
return {
ui.Paragraph(self._area, { left }),
ui.Paragraph(self._area, { right }):align(ui.Paragraph.RIGHT),
table.unpack(Progress:render(self._area, right:width())),
}
end |
Beta Was this translation helpful? Give feedback.
-
How do I replace the permissions on the right with the modified date of the file? |
Beta Was this translation helpful? Give feedback.
Linemode has been simplified, and you can now directly extend a new
custom
method forLinemode
:And make sure you have:
[manager] linemode = "custom"
in your
yazi.toml
, Yazi will call yourLinemode:custom()
method automatically.As for the status bar, add the following to your
init.lua
, ma…