From 8780604ade3b499c204ad0d12d8c60e05c2dc40b Mon Sep 17 00:00:00 2001 From: agryphus Date: Mon, 18 Mar 2024 16:07:27 -0400 Subject: [PATCH] Yazi makeover --- misc/.config/yazi/init.lua | 74 ++++++--- misc/.config/yazi/keymap.toml | 10 +- misc/.config/yazi/theme.toml | 285 +++++++++++++++++----------------- misc/.config/yazi/yazi.toml | 52 +++---- 4 files changed, 226 insertions(+), 195 deletions(-) diff --git a/misc/.config/yazi/init.lua b/misc/.config/yazi/init.lua index 9900bad..4a8c462 100644 --- a/misc/.config/yazi/init.lua +++ b/misc/.config/yazi/init.lua @@ -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 + diff --git a/misc/.config/yazi/keymap.toml b/misc/.config/yazi/keymap.toml index a575c4b..0bc2bb9 100644 --- a/misc/.config/yazi/keymap.toml +++ b/misc/.config/yazi/keymap.toml @@ -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" }, ] diff --git a/misc/.config/yazi/theme.toml b/misc/.config/yazi/theme.toml index 26216dd..49988cc 100644 --- a/misc/.config/yazi/theme.toml +++ b/misc/.config/yazi/theme.toml @@ -10,7 +10,7 @@ cwd = { fg = "white", bold = true } # Hovered -hovered = { fg = "black", bg = "lightblue" } +hovered = { reversed = true } preview_hovered = { underline = true } # Find @@ -40,19 +40,19 @@ 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 } progress_normal = { fg = "blue", bg = "black" } -progress_error = { fg = "red", bg = "black" } +progress_error = { fg = "red", bg = "black" } # Permissions permissions_t = { fg = "lightgreen" } @@ -141,84 +141,86 @@ footer = { fg = "black", bg = "white" } [filetype] rules = [ - # Images - { mime = "image/*", fg = "magenta" }, + # Images + { mime = "image/*", fg = "magenta" }, - # Videos - { mime = "video/*", fg = "green" }, - { mime = "audio/*", fg = "green" }, + # Videos + { mime = "video/*", fg = "green" }, + { mime = "audio/*", fg = "green" }, - # Archives - { mime = "application/zip", fg = "red" }, - { mime = "application/gzip", fg = "red" }, - { mime = "application/x-tar", fg = "red" }, - { mime = "application/x-bzip", fg = "red" }, - { mime = "application/x-bzip2", fg = "red" }, - { mime = "application/x-7z-compressed", fg = "red" }, - { mime = "application/x-rar", fg = "red" }, - { mime = "application/xz", fg = "red" }, + # Archives + { mime = "application/zip", fg = "red" }, + { mime = "application/gzip", fg = "red" }, + { mime = "application/x-tar", fg = "red" }, + { mime = "application/x-bzip", fg = "red" }, + { mime = "application/x-bzip2", fg = "red" }, + { mime = "application/x-7z-compressed", fg = "red" }, + { mime = "application/x-rar", fg = "red" }, + { mime = "application/xz", fg = "red" }, - # Documents - # { mime = "application/doc", fg = "green" }, - { mime = "application/pdf", fg = "magenta" }, - # { mime = "application/rtf", fg = "green" }, - # { mime = "application/vnd.*", fg = "green" }, + # Documents + # { mime = "application/doc", fg = "green" }, + { mime = "application/pdf", fg = "magenta" }, + # { mime = "application/rtf", fg = "green" }, + # { mime = "application/vnd.*", fg = "green" }, - # Fallback - # { name = "*", fg = "white" }, - { name = "*", fg = "yellow", bold = true, is = "exec" }, - { name = "*/", fg = "blue", bold = true } + # Fallback + # { name = "*", fg = "white" }, + { 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 } ] [icon] rules = [ - # Programming - { name = "*.cpp" , text = "", fg = "#519aba" }, - { name = "*.css" , text = "", fg = "#42a5f5" }, - { name = "*.c" , text = "", fg = "#599eff" }, - { name = "*.fish" , text = "" }, - { name = "*.go" , text = "", fg = "#519aba" }, - { name = "*.hpp" , text = "", fg = "#a074c4" }, - { name = "*.h" , text = "", fg = "#a074c4" }, - { name = "*.htm" , text = "", fg = "#e44d26" }, - { name = "*.html" , text = "", fg = "#e44d26" }, - { name = "*.java" , text = "", fg = "#cc3e44" }, - { name = "*.js" , text = "", fg = "#F1F134" }, - { name = "*.jsx" , text = "", fg = "#20c2e3" }, - { name = "*.lua" , text = "", fg = "#51a0cf" }, - { name = "*.nix" , text = "", fg = "#7ab1db" }, - { name = "*.php" , text = "" }, - { name = "*.rb" , text = "" }, - { name = "*.rs" , text = "", fg = "#dea584" }, - { name = "*.scss" , text = "" }, - { name = "*.sh" , text = "", fg = "#4d5a5e" }, - { name = "*.swift", text = "" }, - { name = "*.ts" , text = "", fg = "#519aba" }, - { name = "*.tsx" , text = "" }, - { name = "*.vim" , text = "" }, - { name = "*.vue" , text = "󰡄" }, - { name = "*.py" , text = "", fg = "#ffbc03" }, - { name = "*.pyc" , text = "", fg = "#ffe291" }, + # Programming + { name = "*.cpp" , text = "", fg = "#519aba" }, + { name = "*.css" , text = "", fg = "#42a5f5" }, + { name = "*.c" , text = "", fg = "#599eff" }, + { name = "*.fish" , text = "" }, + { name = "*.go" , text = "", fg = "#519aba" }, + { name = "*.hpp" , text = "", fg = "#a074c4" }, + { name = "*.h" , text = "", fg = "#a074c4" }, + { name = "*.htm" , text = "", fg = "#e44d26" }, + { name = "*.html" , text = "", fg = "#e44d26" }, + { name = "*.java" , text = "", fg = "#cc3e44" }, + { name = "*.js" , text = "", fg = "#F1F134" }, + { name = "*.jsx" , text = "", fg = "#20c2e3" }, + { name = "*.lua" , text = "", fg = "#51a0cf" }, + { name = "*.nix" , text = "", fg = "#7ab1db" }, + { name = "*.php" , text = "" }, + { name = "*.rb" , text = "" }, + { name = "*.rs" , text = "", fg = "#dea584" }, + { name = "*.scss" , text = "" }, + { name = "*.sh" , text = "", fg = "#4d5a5e" }, + { name = "*.swift", text = "" }, + { name = "*.ts" , text = "", fg = "#519aba" }, + { name = "*.tsx" , text = "" }, + { name = "*.vim" , text = "" }, + { name = "*.vue" , text = "󰡄" }, + { name = "*.py" , text = "", fg = "#ffbc03" }, + { name = "*.pyc" , text = "", fg = "#ffe291" }, - # Text - { name = "*.txt" , text = "", fg = "#bbbbbb" }, - { name = "*.csv" , text = "", fg = "#89e051" }, - { name = "*.json" , text = "", fg = "#cbcb41" }, - { name = "*.conf" , text = "", fg = "#6d8086" }, # Configuration - { name = "*.ini" , text = "", fg = "#6d8086" }, - { name = "*.yaml" , text = "", fg = "#6d8086" }, - { name = "*.yml" , text = "", fg = "#6d8086" }, - { name = "*.toml" , text = "", fg = "#6d8086" }, - { name = "*.org" , text = "", fg = "#77aa99" }, - { name = "*.tex" , text = "󰙩", fg = "#3d6117" }, # Plaintext typesetting - { name = "*.typ" , text = "󰙩", fg = "#0e606a" }, - { name = "*.markdown", text = "", fg = "#519aba" }, # Markdown - { name = "*.md" , text = "", fg = "#519aba" }, - { name = "*.mdx" , text = "", fg = "#519aba" }, - { name = "*.rmd" , text = "", fg = "#519aba" }, + # Text + { name = "*.txt" , text = "", fg = "#bbbbbb" }, + { name = "*.csv" , text = "", fg = "#89e051" }, + { name = "*.json" , text = "", fg = "#cbcb41" }, + { name = "*.conf" , text = "", fg = "#6d8086" }, # Configuration + { name = "*.ini" , text = "", fg = "#6d8086" }, + { name = "*.yaml" , text = "", fg = "#6d8086" }, + { name = "*.yml" , text = "", fg = "#6d8086" }, + { name = "*.toml" , text = "", fg = "#6d8086" }, + { name = "*.org" , text = "", fg = "#77aa99" }, + { name = "*.tex" , text = "󰙩", fg = "#3d6117" }, # Plaintext typesetting + { name = "*.typ" , text = "󰙩", fg = "#0e606a" }, + { name = "*.markdown", text = "", fg = "#519aba" }, # Markdown + { name = "*.md" , text = "", fg = "#519aba" }, + { name = "*.mdx" , text = "", fg = "#519aba" }, + { name = "*.rmd" , text = "", fg = "#519aba" }, - # Archives + # Archives { name = "*.7z" , text = "" }, { name = "*.ace" , text = "" }, { name = "*.alz" , text = "" }, @@ -266,7 +268,7 @@ rules = [ { name = "*.zst" , text = "" }, { name = "*.z" , text = "" }, - # Images + # Images { name = "*.bmp" , text = "" }, # Lossless { name = "*.gif" , text = "" }, { name = "*.png" , text = "" }, @@ -288,7 +290,7 @@ rules = [ { name = "*.xbm" , text = "" }, { name = "*.xpm" , text = "" }, - # Movies + # Movies { name = "*.asf" , text = "" }, { name = "*.avi" , text = "" }, { name = "*.cgm" , text = "" }, @@ -320,78 +322,79 @@ rules = [ { name = "*.xwd" , text = "" }, { name = "*.yuv" , text = "" }, - # Audio - { name = "*.aac" , text = "" }, - { name = "*.au" , text = "" }, - { name = "*.flac", text = "" }, - { name = "*.m4a" , text = "" }, - { name = "*.mid" , text = "" }, - { name = "*.midi", text = "" }, - { name = "*.mka" , text = "" }, - { name = "*.mp3" , text = "" }, - { name = "*.mpc" , text = "" }, - { name = "*.oga" , text = "" }, - { name = "*.ogg" , text = "" }, - { name = "*.opus", text = "" }, - { name = "*.ra" , text = "" }, - { name = "*.spx" , text = "" }, - { name = "*.wav" , text = "" }, - { name = "*.xspf", text = "" }, + # Audio + { name = "*.aac" , text = "" }, + { name = "*.au" , text = "" }, + { name = "*.flac", text = "" }, + { name = "*.m4a" , text = "" }, + { name = "*.mid" , text = "" }, + { name = "*.midi", text = "" }, + { name = "*.mka" , text = "" }, + { name = "*.mp3" , text = "" }, + { name = "*.mpc" , text = "" }, + { name = "*.oga" , text = "" }, + { name = "*.ogg" , text = "" }, + { name = "*.opus", text = "" }, + { name = "*.ra" , text = "" }, + { name = "*.spx" , text = "" }, + { name = "*.wav" , text = "" }, + { name = "*.xspf", text = "" }, - # Documents - { name = "*.pdf" , text = "", fg = "#b30b00" }, # Printable - { name = "*.doc" , text = "", fg = "#185abd" }, # Non plaintext docs - { name = "*.doct", text = "", fg = "#185abd" }, - { name = "*.docx", text = "", fg = "#185abd" }, + # Documents + { name = "*.pdf" , text = "", fg = "#b30b00" }, # Printable + { name = "*.doc" , text = "", fg = "#185abd" }, # Non plaintext docs + { name = "*.doct", text = "", fg = "#185abd" }, + { name = "*.docx", text = "", fg = "#185abd" }, { name = "*.dot" , text = "", fg = "#185abd" }, - { name = "*.pom" , text = "󰈩", fg = "#cb4a32" }, # Presentations - { name = "*.pot" , text = "󰈩", fg = "#cb4a32" }, - { name = "*.potx", text = "󰈩", fg = "#cb4a32" }, - { name = "*.ppm" , text = "󰈩", fg = "#cb4a32" }, - { name = "*.ppmx", text = "󰈩", fg = "#cb4a32" }, - { name = "*.pps" , text = "󰈩", fg = "#cb4a32" }, - { name = "*.ppsx", text = "󰈩", fg = "#cb4a32" }, - { name = "*.ppt" , text = "󰈩", fg = "#cb4a32" }, - { name = "*.pptx", text = "󰈩", fg = "#cb4a32" }, - { name = "*.xlc" , text = "" }, - { name = "*.xlm" , text = "" }, - { name = "*.xls" , text = "" }, - { name = "*.xlsm", text = "" }, - { name = "*.xlsx", text = "" }, - { name = "*.xlt" , text = "" }, - { name = "*.ods" , text = "" }, - { name = "*.ots" , text = "" }, - { name = "*.odg" , text = "󰽉" }, + { name = "*.pom" , text = "󰈩", fg = "#cb4a32" }, # Presentations + { name = "*.pot" , text = "󰈩", fg = "#cb4a32" }, + { name = "*.potx", text = "󰈩", fg = "#cb4a32" }, + { name = "*.ppm" , text = "󰈩", fg = "#cb4a32" }, + { name = "*.ppmx", text = "󰈩", fg = "#cb4a32" }, + { name = "*.pps" , text = "󰈩", fg = "#cb4a32" }, + { name = "*.ppsx", text = "󰈩", fg = "#cb4a32" }, + { name = "*.ppt" , text = "󰈩", fg = "#cb4a32" }, + { name = "*.pptx", text = "󰈩", fg = "#cb4a32" }, + { name = "*.xlc" , text = "" }, + { name = "*.xlm" , text = "" }, + { name = "*.xls" , text = "" }, + { name = "*.xlsm", text = "" }, + { name = "*.xlsx", text = "" }, + { name = "*.xlt" , text = "" }, + { name = "*.ods" , text = "" }, + { name = "*.ots" , text = "" }, + { name = "*.odg" , text = "󰽉" }, - # Lockfiles - { name = "*.lock", text = "", fg = "#bbbbbb" }, + # Lockfiles + { name = "*.lock", text = "", fg = "#bbbbbb" }, - # Misc - { name = "*.bin", text = "" }, - { name = "*.exe", text = "" }, - { name = "*.pkg", text = "" }, + # Misc + { name = "*.bin", text = "" }, + { name = "*.exe", text = "" }, + { name = "*.pkg", text = "" }, - # Dotfiles - { name = ".DS_Store" , text = "" }, - { name = ".bashprofile" , text = "" }, - { name = ".bashrc" , text = "" }, - { name = ".gitattributes", text = "" }, - { name = ".gitignore" , text = "" }, - { name = ".gitmodules" , text = "" }, - { name = ".vimrc" , text = "" }, - { name = ".zprofile" , text = "" }, - { name = ".zshenv" , text = "" }, - { name = ".zshrc" , text = "" }, + # Dotfiles + { name = ".DS_Store" , text = "" }, + { name = ".bashprofile" , text = "" }, + { name = ".bashrc" , text = "" }, + { name = ".gitattributes", text = "" }, + { name = ".gitignore" , text = "" }, + { name = ".gitmodules" , text = "" }, + { name = ".vimrc" , text = "" }, + { name = ".zprofile" , text = "" }, + { name = ".zshenv" , text = "" }, + { name = ".zshrc" , text = "" }, - # Named files - { name = "COPYING" , text = "󰿃" }, - { name = "Containerfile", text = "󰡨", fg = "#458ee6" }, - { name = "Dockerfile" , text = "󰡨", fg = "#458ee6" }, - { name = "LICENSE" , text = "", fg = "#d0bf41" }, + # Named files + { name = "COPYING" , text = "󰿃" }, + { name = "Containerfile", text = "󰡨", fg = "#458ee6" }, + { name = "Dockerfile" , text = "󰡨", fg = "#458ee6" }, + { name = "LICENSE" , text = "", fg = "#d0bf41" }, - # Default - { name = "*" , text = "" }, - { name = "*/", text = "󰝰", fg = "yellow" }, + # Default + { name = "*", text = "", is = "exec" }, + { name = "*" , text = "" }, + { name = "*/", text = "󰝰", fg = "yellow" }, ] # : }}} diff --git a/misc/.config/yazi/yazi.toml b/misc/.config/yazi/yazi.toml index 9d6e209..b6cdc14 100644 --- a/misc/.config/yazi/yazi.toml +++ b/misc/.config/yazi/yazi.toml @@ -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]