Yazi makeover

This commit is contained in:
agryphus 2024-03-18 16:07:27 -04:00
parent 49e4e79ed4
commit 8780604ade
4 changed files with 226 additions and 195 deletions

View file

@ -40,27 +40,53 @@ function Manager:render(area)
end
-- Show user and hostname in top bar
-- function Header:host()
-- return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue")
-- end
--
-- function Header:layout(area)
-- self.area = area
--
-- return ui.Layout()
-- :direction(ui.Layout.HORIZONTAL)
-- :constraints({ ui.Constraint.Percentage(50), ui.Constraint.Percentage(50) })
-- :split(area)
-- end
--
-- function Header:render(area)
-- local chunks = self:layout(area)
--
-- local left = ui.Line { self:host(), self:cwd() }
-- local right = ui.Line { self:tabs() }
-- return {
-- ui.Paragraph(chunks[1], { left }),
-- ui.Paragraph(chunks[2], { right }):align(ui.Paragraph.RIGHT),
-- }
-- end
--
function Header:host()
if ya.target_family() ~= "unix" then
return ui.Line {}
end
return ui.Line { ui.Span(ya.user_name() .. "@" .. ya.host_name()):fg("lightgreen"):bold(true), ui.Span(":") }
end
function Header:render(area)
self.area = area
local right = ui.Line { self:count(), self:tabs() }
local left = ui.Line {
self:host(),
self:cwd(math.max(0, area.w - right:width())):fg("blue"),
ui.Span("/"):fg("blue"):bold(true),
ui.Span(tostring(cx.active.current.hovered.name)):fg("white"):bold(true),
}
return {
ui.Paragraph(area, { left }),
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
}
end
-- Show symlink path in status bar
function Status:name()
local h = cx.active.current.hovered
if not h then
return ui.Span("")
end
local linked = ""
if h.link_to ~= nil then
linked = " -> " .. tostring(h.link_to)
end
return ui.Span(" " .. h.name .. linked)
end
-- Remove file size from status bar
function Status:render(area)
self.area = area
local left = ui.Line { self:mode(), self:name() }
local right = ui.Line { self:permissions(), self:position() }
return {
ui.Paragraph(area, { left }),
ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT),
table.unpack(Progress:render(area, right:width())),
}
end

View file

@ -5,10 +5,12 @@
[manager]
prepend_keymap = [
{ on = [ "l" ], exec = [ "plugin smart-enter --sync", "escape --visual --select" ], desc = "Enter the child directory, or open file." },
{ on = [ "L" ], exec = "plugin smart-enter --sync --args='detatch'", desc = "Open in new window." },
{ on = [ "n" ], exec = "create", desc = "Create a file or directory (ends with / for directories)" },
{ on = [ "=" ], exec = """
{ on = [ "j" ], run = [ "plugin --sync arrow --args=1"], desc = "Move selection downwards, or wrap." },
{ on = [ "k" ], run = [ "plugin --sync arrow --args=-1"], desc = "Move selection upwards, or wrap." },
{ on = [ "l" ], run = [ "plugin smart-enter --sync", "escape --visual --select" ], desc = "Enter the child directory, or open file." },
{ on = [ "L" ], run = "plugin smart-enter --sync --args='detatch'", desc = "Open in new window." },
{ on = [ "n" ], run = "create", desc = "Create a file or directory (ends with / for directories)" },
{ on = [ "=" ], run = """
shell 'printf "Mode Bits: "; read ans; chmod $ans "$@"' --block --confirm
""", desc = "chmod" },
]

View file

@ -10,7 +10,7 @@
cwd = { fg = "white", bold = true }
# Hovered
hovered = { fg = "black", bg = "lightblue" }
hovered = { reversed = true }
preview_hovered = { underline = true }
# Find
@ -40,14 +40,14 @@ syntect_theme = ""
# : Status {{{
[status]
separator_open = ""
separator_close = ""
separator_open = ""
separator_close = ""
separator_style = { fg = "darkgray", bg = "darkgray" }
# Mode
mode_normal = { fg = "black", bg = "lightblue", bold = true }
mode_select = { fg = "black", bg = "lightgreen", bold = true }
mode_unset = { fg = "black", bg = "lightmagenta", bold = true }
mode_normal = { fg = "black", bg = "lightblue", bold = false }
mode_select = { fg = "black", bg = "lightgreen", bold = false }
mode_unset = { fg = "black", bg = "lightmagenta", bold = false }
# Progress
progress_label = { bold = true }
@ -166,7 +166,9 @@ rules = [
# Fallback
# { name = "*", fg = "white" },
{ name = "*", fg = "yellow", bold = true, is = "exec" },
{ name = "*", fg = "cyan", bold = true, is = "link" },
{ name = "*", fg = "green", bold = true, is = "exec" },
{ name = "*/", fg = "cyan", bold = true, is = "link" },
{ name = "*/", fg = "blue", bold = true }
]
@ -390,6 +392,7 @@ rules = [
{ name = "LICENSE" , text = "", fg = "#d0bf41" },
# Default
{ name = "*", text = "", is = "exec" },
{ name = "*" , text = "" },
{ name = "*/", text = "󰝰", fg = "yellow" },
]

View file

@ -10,7 +10,7 @@ sort_reverse = false
sort_dir_first = true
linemode = "size"
show_hidden = true
show_symlink = true
show_symlink = false
[preview]
tab_size = 2
@ -25,7 +25,7 @@ ueberzug_offset = [ 0, 0, 0, 0 ]
[opener]
open = [
{ exec = 'opener "$@"', block = true, desc = "Open" },
{ run = 'opener "$@"', block = true, desc = "Open" },
]
[open]
@ -46,42 +46,42 @@ suppress_preload = false
[plugin]
preloaders = [
{ name = "*", cond = "!mime", exec = "mime", multi = true, prio = "high" },
{ name = "*", cond = "!mime", run = "mime", multi = true, prio = "high" },
# Image
{ mime = "image/vnd.djvu", exec = "noop" },
{ mime = "image/*", exec = "image" },
{ mime = "image/vnd.djvu", run = "noop" },
{ mime = "image/*", run = "image" },
# Video
{ mime = "video/*", exec = "video" },
{ mime = "video/*", run = "video" },
# PDF
{ mime = "application/pdf", exec = "pdf" },
{ mime = "application/pdf", run = "pdf" },
]
previewers = [
{ name = "*/", exec = "folder", sync = true },
{ name = "*/", run = "folder", sync = true },
# Code
{ mime = "text/*", exec = "code" },
{ mime = "*/xml", exec = "code" },
{ mime = "*/javascript", exec = "code" },
{ mime = "*/x-wine-extension-ini", exec = "code" },
{ mime = "text/*", run = "code" },
{ mime = "*/xml", run = "code" },
{ mime = "*/javascript", run = "code" },
{ mime = "*/x-wine-extension-ini", run = "code" },
# JSON
{ mime = "application/json", exec = "json" },
{ mime = "application/json", run = "json" },
# Image
{ mime = "image/vnd.djvu", exec = "noop" },
{ mime = "image/*", exec = "image" },
{ mime = "image/vnd.djvu", run = "noop" },
{ mime = "image/*", run = "image" },
# Video
{ mime = "video/*", exec = "video" },
{ mime = "video/*", run = "video" },
# PDF
{ mime = "application/pdf", exec = "pdf" },
{ mime = "application/pdf", run = "pdf" },
# Archive
{ mime = "application/zip", exec = "archive" },
{ mime = "application/gzip", exec = "archive" },
{ mime = "application/x-tar", exec = "archive" },
{ mime = "application/x-bzip", exec = "archive" },
{ mime = "application/x-bzip2", exec = "archive" },
{ mime = "application/x-7z-compressed", exec = "archive" },
{ mime = "application/x-rar", exec = "archive" },
{ mime = "application/xz", exec = "archive" },
{ mime = "application/zip", run = "archive" },
{ mime = "application/gzip", run = "archive" },
{ mime = "application/x-tar", run = "archive" },
{ mime = "application/x-bzip", run = "archive" },
{ mime = "application/x-bzip2", run = "archive" },
{ mime = "application/x-7z-compressed", run = "archive" },
{ mime = "application/x-rar", run = "archive" },
{ mime = "application/xz", run = "archive" },
# Fallback
{ name = "*", exec = "file" },
{ name = "*", run = "file" },
]
[input]