From 7ee19657e5444bd3388cb1ea3d53be73fbffe1c2 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 23 Feb 2024 04:22:49 +0100 Subject: [PATCH 01/10] add rga --- .config/ripgrep-all/config.jsonc | 58 ++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .config/ripgrep-all/config.jsonc diff --git a/.config/ripgrep-all/config.jsonc b/.config/ripgrep-all/config.jsonc new file mode 100644 index 0000000..0c9ffe2 --- /dev/null +++ b/.config/ripgrep-all/config.jsonc @@ -0,0 +1,58 @@ +{ + "custom_adapters": [ + { + "name": "tesseract", + "version": 1, + "description": "Uses Tesseract OCR to recognize text in image files", + "extensions": [ + "jpg", + "jpeg", + "jpe", + "png", + "webp", + "gif", + "tif", + "tiff", + "jp2", + "j2k", + "jpf", + "jpm", + "jpg2", + "jpg2000", + "jpeg2000", + "j2c", + "jpc", + "jpx", + "bmp", + "pnm" + ], + "mimetypes": [ + "image/jpeg", + "image/png", + "image/webp", + "image/gif", + "image/tiff", + "image/jp2", + "image/jpx", + "image/jpm", + "image/bmp", + "image/x-portable-anymap" + ], + "binary": "tesseract", + "args": ["--psm", "1", "-", "-"], + "disabled_by_default": false, + "match_only_by_mime": false + }, + { + "args": [], + "binary": "gron", + "description": "Transform JSON into discrete JS assignments", + "disabled_by_default": false, + "extensions": ["json", "jsonc"], + "match_only_by_mime": false, + "mimetypes": ["application/json"], + "name": "gron", + "version": 1 + } + ] +} From 3dee11eca6e357b21e96b5dad02d2499b061ffcf Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 23 Feb 2024 04:30:37 +0100 Subject: [PATCH 02/10] add dunst --- .config/dunst/dunstrc | 52 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 .config/dunst/dunstrc diff --git a/.config/dunst/dunstrc b/.config/dunst/dunstrc new file mode 100755 index 0000000..a236e1a --- /dev/null +++ b/.config/dunst/dunstrc @@ -0,0 +1,52 @@ +[global] +follow = mouse +indicate_hidden = yes +offset = 10x10 +notification_height = 0 + +separator_height = 2 + +padding = 8 +horizontal_padding = 8 +text_icon_padding = 0 +frame_width = 2 + +frame_color = "#351c75" +separator_color = frame + +sort = yes +idle_threshold = 120 +font = monospace 10 +line_height = 0 +markup = full +alignment = left +vertical_alignment = center +show_age_threshold = 60 +word_wrap = yes +stack_duplicates = true +hide_duplicate_count = false + +show_indicators = yes + +min_icon_size = 0 +max_icon_size = 64 + +browser = /usr/bin/firefox --new-tab + +title = Dunst +class = Dunst + +corner_radius = 10 +timeout = 5 +[urgency_low] +background = "#1E1E2E" +foreground = "#CDD6F4" + +[urgency_normal] +background = "#1E1E2E" +foreground = "#CDD6F4" + +[urgency_critical] +background = "#1E1E2E" +foreground = "#CDD6F4" +frame_color = "#cc0000" From ad286ec3f7d9513148450264f0005ab221ad8869 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Fri, 23 Feb 2024 04:33:06 +0100 Subject: [PATCH 03/10] add mpv --- .config/mpv/input.conf | 5 +++++ .config/mpv/mpv.conf | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .config/mpv/input.conf create mode 100644 .config/mpv/mpv.conf diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf new file mode 100644 index 0000000..5c94dae --- /dev/null +++ b/.config/mpv/input.conf @@ -0,0 +1,5 @@ +# decrease the playback speed +s multiply speed 1/1.1 + +# increase the playback speed +d multiply speed 1.1 diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf new file mode 100644 index 0000000..a589271 --- /dev/null +++ b/.config/mpv/mpv.conf @@ -0,0 +1,9 @@ +alang=de,en,es,ja + +auto-window-resize=no +autofit=100% + +[youtube] +profile-cond=path:find('youtu%.?be') +speed=2.0 +ytdl-format=bestvideo[height<=1440]+bestaudio/best From 04e857d96eb9506c76e462a74e321fcf925919cc Mon Sep 17 00:00:00 2001 From: JMARyA Date: Mon, 4 Mar 2024 23:30:18 +0100 Subject: [PATCH 04/10] add yazi --- .config/yazi/init.lua | 103 ++++++ .config/yazi/keymap.toml | 14 + .config/yazi/plugins/7z.yazi/init.lua | 63 ++++ .config/yazi/plugins/glow.yazi/init.lua | 66 ++++ .config/yazi/plugins/hexyl.yazi/init.lua | 57 ++++ .config/yazi/plugins/imdl.yazi/init.lua | 64 ++++ .../yazi/plugins/smart-enter.yazi/init.lua | 6 + .config/yazi/theme.toml | 307 ++++++++++++++++++ .config/yazi/yazi.toml | 120 +++++++ 9 files changed, 800 insertions(+) create mode 100644 .config/yazi/init.lua create mode 100644 .config/yazi/keymap.toml create mode 100644 .config/yazi/plugins/7z.yazi/init.lua create mode 100644 .config/yazi/plugins/glow.yazi/init.lua create mode 100644 .config/yazi/plugins/hexyl.yazi/init.lua create mode 100644 .config/yazi/plugins/imdl.yazi/init.lua create mode 100644 .config/yazi/plugins/smart-enter.yazi/init.lua create mode 100644 .config/yazi/theme.toml create mode 100644 .config/yazi/yazi.toml diff --git a/.config/yazi/init.lua b/.config/yazi/init.lua new file mode 100644 index 0000000..40ea142 --- /dev/null +++ b/.config/yazi/init.lua @@ -0,0 +1,103 @@ +Manager = { + area = ui.Rect.default, +} + +function Manager:layout(area) + self.area = area + + return ui.Layout() + :direction(ui.Layout.HORIZONTAL) + :constraints({ + ui.Constraint.Ratio(MANAGER.ratio.parent, MANAGER.ratio.all), + ui.Constraint.Ratio(MANAGER.ratio.current, MANAGER.ratio.all), + ui.Constraint.Ratio(MANAGER.ratio.preview, MANAGER.ratio.all), + }) + :split(area) +end + +function Manager:render(area) + local chunks = self:layout(area) + + local bar = function(c, x, y) + x, y = math.max(0, x), math.max(0, y) + return ui.Bar(ui.Rect { x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }, ui.Bar.TOP) + :symbol(c) + end + + return ya.flat { + -- Borders + ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED), + ui.Bar(chunks[1], ui.Bar.RIGHT), + ui.Bar(chunks[3], ui.Bar.LEFT), + + bar("┬", chunks[1].right - 1, chunks[1].y), + bar("┴", chunks[1].right - 1, chunks[1].bottom - 1), + bar("┬", chunks[2].right, chunks[2].y), + bar("┴", chunks[2].right, chunks[1].bottom - 1), + + -- Parent + Parent:render(chunks[1]:padding(ui.Padding.xy(1))), + -- Current + Current:render(chunks[2]:padding(ui.Padding.y(1))), + -- Preview + Preview:render(chunks[3]:padding(ui.Padding.xy(1))), + } +end + +function Header:host() + if ya.target_family() ~= "unix" then + return ui.Line {} + end + return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue") +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 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:mtime() + local h = cx.active.current.hovered + if h == nil or ya.target_family() ~= "unix" then + return ui.Line {} + end + + -- fix unix timestamp format + return ui.Line { + ui.Span(h.cha.modified):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:mtime(), self:owner(), self:percentage(), self:position() } + local right = ui.Line { self:owner(), 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 \ No newline at end of file diff --git a/.config/yazi/keymap.toml b/.config/yazi/keymap.toml new file mode 100644 index 0000000..6e6de70 --- /dev/null +++ b/.config/yazi/keymap.toml @@ -0,0 +1,14 @@ +[[input.prepend_keymap]] +on = [ "" ] +exec = "close" +desc = "Cancel input" + +[[manager.prepend_keymap]] +on = [ "l" ] +exec = "plugin --sync smart-enter" +desc = "Enter the child directory, or open the file" + +[[manager.prepend_keymap]] +on = [ "" ] +exec = "plugin --sync smart-enter" +desc = "Enter the child directory, or open the file" \ No newline at end of file diff --git a/.config/yazi/plugins/7z.yazi/init.lua b/.config/yazi/plugins/7z.yazi/init.lua new file mode 100644 index 0000000..128bdc4 --- /dev/null +++ b/.config/yazi/plugins/7z.yazi/init.lua @@ -0,0 +1,63 @@ +local M = {} + +function M:peek() + local child = Command("7z") + :args({ + "l", + tostring(self.file.url), + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + if not child then + return self:fallback_to_builtin() + end + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + return self:fallback_to_builtin() + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +function M:fallback_to_builtin() + local _, bound = ya.preview_code(self) + if bound then + ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" }) + end +end + +return M \ No newline at end of file diff --git a/.config/yazi/plugins/glow.yazi/init.lua b/.config/yazi/plugins/glow.yazi/init.lua new file mode 100644 index 0000000..d55e9de --- /dev/null +++ b/.config/yazi/plugins/glow.yazi/init.lua @@ -0,0 +1,66 @@ +local M = {} + +function M:peek() + local child = Command("glow") + :args({ + "--style", + "dark", + "--width", + tostring(self.area.w), + tostring(self.file.url), + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + if not child then + return self:fallback_to_builtin() + end + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + return self:fallback_to_builtin() + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +function M:fallback_to_builtin() + local _, bound = ya.preview_code(self) + if bound then + ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" }) + end +end + +return M \ No newline at end of file diff --git a/.config/yazi/plugins/hexyl.yazi/init.lua b/.config/yazi/plugins/hexyl.yazi/init.lua new file mode 100644 index 0000000..939aca7 --- /dev/null +++ b/.config/yazi/plugins/hexyl.yazi/init.lua @@ -0,0 +1,57 @@ +local M = {} + +function M:peek() + local child = Command("hexyl") + :args({ + "--border", + "none", + "-n", + "4092", + "--terminal-width", + tostring(self.area.w), + tostring(self.file.url), + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + ya.err(tostring(event)) + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +return M diff --git a/.config/yazi/plugins/imdl.yazi/init.lua b/.config/yazi/plugins/imdl.yazi/init.lua new file mode 100644 index 0000000..c81a64c --- /dev/null +++ b/.config/yazi/plugins/imdl.yazi/init.lua @@ -0,0 +1,64 @@ +local M = {} + +function M:peek() + local child = Command("imdl") + :args({ + "torrent", + "show", + tostring(self.file.url), + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + if not child then + return self:fallback_to_builtin() + end + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + return self:fallback_to_builtin() + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +function M:fallback_to_builtin() + local _, bound = ya.preview_code(self) + if bound then + ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" }) + end +end + +return M \ No newline at end of file diff --git a/.config/yazi/plugins/smart-enter.yazi/init.lua b/.config/yazi/plugins/smart-enter.yazi/init.lua new file mode 100644 index 0000000..ee7b607 --- /dev/null +++ b/.config/yazi/plugins/smart-enter.yazi/init.lua @@ -0,0 +1,6 @@ +return { + entry = function() + local h = cx.active.current.hovered + ya.manager_emit(h and h.cha.is_dir and "enter" or "open", {}) + end, +} \ No newline at end of file diff --git a/.config/yazi/theme.toml b/.config/yazi/theme.toml new file mode 100644 index 0000000..90c2722 --- /dev/null +++ b/.config/yazi/theme.toml @@ -0,0 +1,307 @@ +[manager] +cwd = { fg = "cyan" } + +# Hovered +hovered = { fg = "black", bg = "lightblue" } +preview_hovered = { underline = true } + +# Find +find_keyword = { fg = "yellow", italic = true } +find_position = { fg = "magenta", bg = "reset", italic = true } + +# Marker +marker_selected = { fg = "lightgreen", bg = "lightgreen" } +marker_copied = { fg = "lightyellow", bg = "lightyellow" } +marker_cut = { fg = "lightred", bg = "lightred" } + +# Tab +tab_active = { fg = "black", bg = "lightblue" } +tab_inactive = { fg = "white", bg = "darkgray" } +tab_width = 1 + +# Border +border_symbol = "│" +border_style = { fg = "gray" } + +# Highlighting +syntect_theme = "" + +# : }}} + + +# : Status {{{ + +[status] +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 } + +# Progress +progress_label = { bold = true } +progress_normal = { fg = "blue", bg = "black" } +progress_error = { fg = "red", bg = "black" } + +# Permissions +permissions_t = { fg = "lightgreen" } +permissions_r = { fg = "lightyellow" } +permissions_w = { fg = "lightred" } +permissions_x = { fg = "lightcyan" } +permissions_s = { fg = "darkgray" } + +# : }}} + + +# : Select {{{ + +[select] +border = { fg = "blue" } +active = { fg = "magenta" } +inactive = {} + +# : }}} + + +# : Input {{{ + +[input] +border = { fg = "blue" } +title = {} +value = {} +selected = { reversed = true } + +# : }}} + + +# : Completion {{{ + +[completion] +border = { fg = "blue" } +active = { bg = "darkgray" } +inactive = {} + +# Icons +icon_file = "" +icon_folder = "" +icon_command = "" + +# : }}} + + +# : Tasks {{{ + +[tasks] +border = { fg = "blue" } +title = {} +hovered = { underline = true } + +# : }}} + + +# : Which {{{ + +[which] +cols = 3 +mask = { bg = "black" } +cand = { fg = "lightcyan" } +rest = { fg = "darkgray" } +desc = { fg = "magenta" } +separator = "  " +separator_style = { fg = "darkgray" } + +# : }}} + + +# : Help {{{ + +[help] +on = { fg = "magenta" } +exec = { fg = "cyan" } +desc = { fg = "gray" } +hovered = { bg = "darkgray", bold = true } +footer = { fg = "black", bg = "white" } + +# : }}} + + +# : File-specific styles {{{ + +[filetype] + +rules = [ + # Images + { mime = "image/*", fg = "cyan" }, + + # Videos + { mime = "video/*", fg = "yellow" }, + { mime = "audio/*", fg = "yellow" }, + + # Archives + { mime = "application/zip", fg = "magenta" }, + { mime = "application/gzip", fg = "magenta" }, + { mime = "application/x-tar", fg = "magenta" }, + { mime = "application/x-bzip", fg = "magenta" }, + { mime = "application/x-bzip2", fg = "magenta" }, + { mime = "application/x-7z-compressed", fg = "magenta" }, + { mime = "application/x-rar", fg = "magenta" }, + { mime = "application/xz", fg = "magenta" }, + + # Documents + { mime = "application/doc", fg = "green" }, + { mime = "application/pdf", fg = "green" }, + { mime = "application/rtf", fg = "green" }, + { mime = "application/vnd.*", fg = "green" }, + + # Fallback + # { name = "*", fg = "white" }, + { name = "*/", fg = "blue" } +] + +[icon] + +rules = [ + # Programming + { name = "*.c" , text = "" }, + { name = "*.cpp" , text = "" }, + { name = "*.css" , text = "" }, + { name = "*.fish" , text = "" }, + { name = "*.go" , text = "" }, + { name = "*.h" , text = "" }, + { name = "*.hpp" , text = "" }, + { name = "*.html" , text = "" }, + { name = "*.java" , text = "" }, + { name = "*.js" , text = "" }, + { name = "*.jsx" , text = "" }, + { name = "*.lua" , text = "" }, + { name = "*.nix" , text = "" }, + { name = "*.php" , text = "" }, + { name = "*.py" , text = "" }, + { name = "*.rb" , text = "" }, + { name = "*.rs" , text = "" }, + { name = "*.scss" , text = "" }, + { name = "*.sh" , text = "" }, + { name = "*.swift", text = "" }, + { name = "*.ts" , text = "" }, + { name = "*.tsx" , text = "" }, + { name = "*.vim" , text = "" }, + { name = "*.vue" , text = "󰡄" }, + + # Text + { name = "*.conf", text = "" }, + { name = "*.ini" , text = "" }, + { name = "*.json", text = "" }, + { name = "*.md" , text = "" }, + { name = "*.toml", text = "" }, + { name = "*.txt", text = "" }, + { name = "*.yaml", text = "" }, + { name = "*.yml" , text = "" }, + + # Archives + { name = "*.7z" , text = "" }, + { name = "*.bz2", text = "" }, + { name = "*.gz" , text = "" }, + { name = "*.rar", text = "" }, + { name = "*.tar", text = "" }, + { name = "*.xz" , text = "" }, + { name = "*.zip", text = "" }, + + # Images + { name = "*.HEIC", text = "" }, + { name = "*.avif", text = "" }, + { name = "*.bmp" , text = "" }, + { name = "*.gif" , text = "" }, + { name = "*.ico" , text = "" }, + { name = "*.jpeg", text = "" }, + { name = "*.jpg" , text = "" }, + { name = "*.png" , text = "" }, + { name = "*.svg" , text = "" }, + { name = "*.webp", text = "" }, + + # Movies + { name = "*.avi" , text = "" }, + { name = "*.mkv" , text = "" }, + { name = "*.mov" , text = "" }, + { name = "*.mp4" , text = "" }, + { name = "*.webm", text = "" }, + + # Audio + { name = "*.aac" , text = "" }, + { name = "*.flac", text = "" }, + { name = "*.m4a" , text = "" }, + { name = "*.mp3" , text = "" }, + { name = "*.ogg" , text = "" }, + { name = "*.wav" , text = "" }, + + # Documents + { name = "*.csv" , text = "" }, + { name = "*.doc" , text = "" }, + { name = "*.doct", text = "" }, + { name = "*.docx", text = "" }, + { name = "*.dot" , text = "" }, + { name = "*.ods" , text = "" }, + { name = "*.ots" , text = "" }, + { name = "*.pdf" , text = "" }, + { name = "*.pom" , text = "" }, + { name = "*.pot" , text = "" }, + { name = "*.potx", text = "" }, + { name = "*.ppm" , text = "" }, + { name = "*.ppmx", text = "" }, + { name = "*.pps" , text = "" }, + { name = "*.ppsx", text = "" }, + { name = "*.ppt" , text = "" }, + { name = "*.pptx", text = "" }, + { name = "*.xlc" , text = "" }, + { name = "*.xlm" , text = "" }, + { name = "*.xls" , text = "" }, + { name = "*.xlsm", text = "" }, + { name = "*.xlsx", text = "" }, + { name = "*.xlt" , text = "" }, + + # Lockfiles + { name = "*.lock", 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 = "" }, + + # Named files + { name = "COPYING" , text = "󰿃" }, + { name = "Containerfile", text = "󰡨" }, + { name = "Dockerfile" , text = "󰡨" }, + { name = "LICENSE" , text = "󰿃" }, + + # Directories + { name = ".config/" , text = "" }, + { name = ".git/" , text = "" }, + { name = "Desktop/" , text = "" }, + { name = "Development/", text = "" }, + { name = "Documents/" , text = "" }, + { name = "Downloads/" , text = "" }, + { name = "Library/" , text = "" }, + { name = "Movies/" , text = "" }, + { name = "Music/" , text = "" }, + { name = "Pictures/" , text = "" }, + { name = "Public/" , text = "" }, + { name = "Videos/" , text = "" }, + + # Default + { name = "*" , text = "" }, + { name = "*/", text = "" }, +] diff --git a/.config/yazi/yazi.toml b/.config/yazi/yazi.toml new file mode 100644 index 0000000..0b23632 --- /dev/null +++ b/.config/yazi/yazi.toml @@ -0,0 +1,120 @@ +[manager] +ratio = [1, 4, 3] +sort_by = "natural" +sort_sensitive=false + +#sort_dir_first=true +sort_dir_first=false + +#linemode="mtime" +linemode="size" + +show_hidden=false +show_symlink=true + +[opener] +edit = [ + { exec = '$EDITOR "$@"', block = true, desc="Edit", for = "unix" }, +] +open = [ + { exec = 'xdg-open "$@"', desc = "Open", for = "linux" }, + { exec = 'open "$@"', desc = "Open", for = "macos" }, + { exec = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" } +] +extract = [ + { exec = '7z x "$1"', desc = "Extract here", for = "unix" }, +] +play = [ + { exec = 'mpv "$@"', orphan = true, desc = "Play", for = "unix" }, + { exec = 'mpv "%1"', orphan = true, desc = "Play", for = "windows" }, +] +info = [ + { exec = '''ffprobe -hide_banner "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show ffprobe info", for = "unix" }, + { exec = '''ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show duration", for = "unix"} +] + +[open] +rules = [ + { name = "*/", use = [ "edit", "open" ] }, + + { mime = "text/*", use = [ "edit" ] }, + { mime = "image/*", use = [ "open" ] }, + { mime = "video/*", use = [ "play", "info" ] }, + { mime = "audio/*", use = [ "play", "info" ] }, + { mime = "inode/x-empty", use = [ "edit" ] }, + + { mime = "application/json", use = [ "edit" ] }, + { mime = "*/javascript", use = [ "edit" ] }, + + { mime = "application/zip", use = [ "extract" ] }, + { mime = "application/gzip", use = [ "extract" ] }, + { mime = "application/x-tar", use = [ "extract" ] }, + { mime = "application/x-bzip", use = [ "extract" ] }, + { mime = "application/x-bzip2", use = [ "extract" ] }, + { mime = "application/x-7z-compressed", use = [ "extract" ] }, + { mime = "application/x-rar", use = [ "extract" ] }, + { mime = "application/xz", use = [ "extract" ] }, + + { mime = "*", use = [ "open" ] }, +] + +[tasks] +micro_workers = 10 +macro_workers = 25 +bizarre_retry = 5 +image_alloc = 536870912 # 512MB +image_bound = [ 0, 0 ] +suppress_preload = false + +[plugin] +prepend_previewers = [ + { name = "*.md", exec = "glow" }, +] + +preloaders = [ + { name = "*", cond = "!mime", exec = "mime", multi = true, prio = "high" }, + # Image + { mime = "image/vnd.djvu", exec = "noop" }, + { mime = "image/*", exec = "image" }, + # Video + { mime = "video/*", exec = "video" }, + # PDF + { mime = "application/pdf", exec = "pdf" }, +] +previewers = [ + { name = "*/", exec = "folder", sync = true }, + # Code + { mime = "text/*", exec = "code" }, + { mime = "*/xml", exec = "code" }, + { mime = "*/javascript", exec = "code" }, + { mime = "*/x-wine-extension-ini", exec = "code" }, + # JSON + { mime = "application/json", exec = "json" }, + # Image + { mime = "image/vnd.djvu", exec = "noop" }, + { mime = "image/*", exec = "image" }, + # Video + { mime = "video/*", exec = "video" }, + # PDF + { mime = "application/pdf", exec = "pdf" }, + # Archive + { mime = "application/zip", exec = "7z" }, + { mime = "application/gzip", exec = "7z" }, + { mime = "application/x-tar", exec = "7z" }, + { mime = "application/x-bzip", exec = "7z" }, + { mime = "application/x-bzip2", exec = "7z" }, + { mime = "application/x-7z-compressed", exec = "7z" }, + { mime = "application/x-rar", exec = "7z" }, + { mime = "application/xz", exec = "7z" }, + { mime = "application/x-bittorrent;", exec = "imdl" }, + { name = "*.torrent", exec = "imdl" }, + + { mime = "application/octet-stream", exec = "hexyl" }, + # Fallback + { name = "*", exec = "file" }, +] + +[select] +open_title = "Open with:" +open_origin = "hovered" +open_offset = [ 0, 1, 50, 7 ] From 96d794798fa24b68ecb27dc386ff530086f9b366 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 7 Mar 2024 01:09:25 +0100 Subject: [PATCH 05/10] update + fixes --- .config/yazi/plugins/7z.yazi/init.lua | 1 + .config/yazi/plugins/imdl.yazi/init.lua | 1 + .config/yazi/plugins/pdf2text.yazi/init.lua | 63 +++++++++++++++++++++ .config/yazi/yazi.toml | 10 +++- 4 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 .config/yazi/plugins/pdf2text.yazi/init.lua diff --git a/.config/yazi/plugins/7z.yazi/init.lua b/.config/yazi/plugins/7z.yazi/init.lua index 128bdc4..c9165a7 100644 --- a/.config/yazi/plugins/7z.yazi/init.lua +++ b/.config/yazi/plugins/7z.yazi/init.lua @@ -4,6 +4,7 @@ function M:peek() local child = Command("7z") :args({ "l", + "-ba", tostring(self.file.url), }) :stdout(Command.PIPED) diff --git a/.config/yazi/plugins/imdl.yazi/init.lua b/.config/yazi/plugins/imdl.yazi/init.lua index c81a64c..2fbb443 100644 --- a/.config/yazi/plugins/imdl.yazi/init.lua +++ b/.config/yazi/plugins/imdl.yazi/init.lua @@ -3,6 +3,7 @@ local M = {} function M:peek() local child = Command("imdl") :args({ + "-t", "torrent", "show", tostring(self.file.url), diff --git a/.config/yazi/plugins/pdf2text.yazi/init.lua b/.config/yazi/plugins/pdf2text.yazi/init.lua new file mode 100644 index 0000000..1e2f9aa --- /dev/null +++ b/.config/yazi/plugins/pdf2text.yazi/init.lua @@ -0,0 +1,63 @@ +local M = {} + +function M:peek() + local child = Command("pdftotext") + :args({ + tostring(self.file.url), + "-" + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + if not child then + return self:fallback_to_builtin() + end + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + return self:fallback_to_builtin() + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +function M:fallback_to_builtin() + local _, bound = ya.preview_code(self) + if bound then + ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" }) + end +end + +return M \ No newline at end of file diff --git a/.config/yazi/yazi.toml b/.config/yazi/yazi.toml index 0b23632..654ac03 100644 --- a/.config/yazi/yazi.toml +++ b/.config/yazi/yazi.toml @@ -30,7 +30,7 @@ play = [ ] info = [ { exec = '''ffprobe -hide_banner "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show ffprobe info", for = "unix" }, - { exec = '''ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show duration", for = "unix"} + { exec = '''printf "'${1##*/}' Duration: ";ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show duration", for = "unix"} ] [open] @@ -96,7 +96,7 @@ previewers = [ # Video { mime = "video/*", exec = "video" }, # PDF - { mime = "application/pdf", exec = "pdf" }, + { mime = "application/pdf", exec = "pdf2text" }, # Archive { mime = "application/zip", exec = "7z" }, { mime = "application/gzip", exec = "7z" }, @@ -109,8 +109,12 @@ previewers = [ { mime = "application/x-bittorrent;", exec = "imdl" }, { name = "*.torrent", exec = "imdl" }, - { mime = "application/octet-stream", exec = "hexyl" }, + # File Ext + # Switch ROM + { name = "*.nsp", exec = "file" }, + # Fallback + { mime = "application/octet-stream", exec = "hexyl" }, { name = "*", exec = "file" }, ] From 30666dca52845d6fd2eb19a5f8f0eff16fb2271b Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sat, 9 Mar 2024 20:09:50 +0100 Subject: [PATCH 06/10] add hydra auth --- .config/mpv/scripts/hydra-auth.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .config/mpv/scripts/hydra-auth.lua diff --git a/.config/mpv/scripts/hydra-auth.lua b/.config/mpv/scripts/hydra-auth.lua new file mode 100644 index 0000000..ac4f0ad --- /dev/null +++ b/.config/mpv/scripts/hydra-auth.lua @@ -0,0 +1,29 @@ +local utils = require("mp.utils") + +function getKey(table, key) + for _, item in ipairs(table) do + local k, v = item:match("([^=]+)=(.+)") + if k == key then + return v + end + end + return nil -- Key not found +end + +function auth() + local url = mp.get_property("stream-open-filename") + if url:find("files.hydrar.de") then + local env = utils.get_env_list() + local auth = getKey(env, "FILES_AUTH") + if auth == nil then + auth = mp.get_opt("FILES_AUTH") + end + if auth ~= nil then + mp.set_property("http-header-fields", "Authorization: Basic " .. auth) + else + print("Authorization value not found.") + end + end +end + +mp.register_event("start-file", auth) From 589c03f4ecd2b3d515308c140fdd38e7eeea7752 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Wed, 13 Mar 2024 16:21:09 +0100 Subject: [PATCH 07/10] add viu --- .config/yazi/plugins/viu.yazi/init.lua | 64 ++++++++++++++++++++++++++ .config/yazi/yazi.toml | 2 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 .config/yazi/plugins/viu.yazi/init.lua diff --git a/.config/yazi/plugins/viu.yazi/init.lua b/.config/yazi/plugins/viu.yazi/init.lua new file mode 100644 index 0000000..bf46f9e --- /dev/null +++ b/.config/yazi/plugins/viu.yazi/init.lua @@ -0,0 +1,64 @@ +local M = {} + +function M:peek() + local child = Command("viu") + :args({ + "--width", + tostring(self.area.w), + tostring(self.file.url), + }) + :stdout(Command.PIPED) + :stderr(Command.PIPED) + :spawn() + + if not child then + return self:fallback_to_builtin() + end + + local limit = self.area.h + local i, lines = 0, "" + repeat + local next, event = child:read_line() + if event == 1 then + return self:fallback_to_builtin() + elseif event ~= 0 then + break + end + + i = i + 1 + if i > self.skip then + lines = lines .. next + end + until i >= self.skip + limit + + child:start_kill() + if self.skip > 0 and i < self.skip + limit then + ya.manager_emit( + "peek", + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" } + ) + else + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size)) + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) + end +end + +function M:seek(units) + local h = cx.active.current.hovered + if h and h.url == self.file.url then + local step = math.floor(units * self.area.h / 10) + ya.manager_emit("peek", { + tostring(math.max(0, cx.active.preview.skip + step)), + only_if = tostring(self.file.url), + }) + end +end + +function M:fallback_to_builtin() + local _, bound = ya.preview_code(self) + if bound then + ya.manager_emit("peek", { tostring(bound), only_if = tostring(self.file.url), upper_bound = "" }) + end +end + +return M \ No newline at end of file diff --git a/.config/yazi/yazi.toml b/.config/yazi/yazi.toml index 654ac03..d360236 100644 --- a/.config/yazi/yazi.toml +++ b/.config/yazi/yazi.toml @@ -92,7 +92,7 @@ previewers = [ { mime = "application/json", exec = "json" }, # Image { mime = "image/vnd.djvu", exec = "noop" }, - { mime = "image/*", exec = "image" }, + { mime = "image/*", exec = "viu" }, # Video { mime = "video/*", exec = "video" }, # PDF From f02ef3f9ca3a49a71953373c6fe1553ed6d8a85f Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 14 Mar 2024 02:11:44 +0100 Subject: [PATCH 08/10] add color for imdl --- .config/yazi/plugins/imdl.yazi/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/yazi/plugins/imdl.yazi/init.lua b/.config/yazi/plugins/imdl.yazi/init.lua index 2fbb443..88a68f1 100644 --- a/.config/yazi/plugins/imdl.yazi/init.lua +++ b/.config/yazi/plugins/imdl.yazi/init.lua @@ -3,6 +3,8 @@ local M = {} function M:peek() local child = Command("imdl") :args({ + "--color", + "always", "-t", "torrent", "show", From b70d88c06fe73981b2d2b2e5c167070a84f3965f Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 14 Mar 2024 09:56:03 +0100 Subject: [PATCH 09/10] yazi update --- .config/yazi/init.lua | 2 +- .config/yazi/keymap.toml | 6 ++-- .config/yazi/yazi.toml | 76 ++++++++++++++++++++-------------------- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/.config/yazi/init.lua b/.config/yazi/init.lua index 40ea142..da80ac1 100644 --- a/.config/yazi/init.lua +++ b/.config/yazi/init.lua @@ -52,7 +52,7 @@ function Header:host() end function Header:render(area) - local chunks = self:layout(area) + local chunks = self:render(area) local left = ui.Line { self:host(), self:cwd() } local right = ui.Line { self:tabs() } diff --git a/.config/yazi/keymap.toml b/.config/yazi/keymap.toml index 6e6de70..ebd3893 100644 --- a/.config/yazi/keymap.toml +++ b/.config/yazi/keymap.toml @@ -1,14 +1,14 @@ [[input.prepend_keymap]] on = [ "" ] -exec = "close" +run = "close" desc = "Cancel input" [[manager.prepend_keymap]] on = [ "l" ] -exec = "plugin --sync smart-enter" +run = "plugin --sync smart-enter" desc = "Enter the child directory, or open the file" [[manager.prepend_keymap]] on = [ "" ] -exec = "plugin --sync smart-enter" +run = "plugin --sync smart-enter" desc = "Enter the child directory, or open the file" \ No newline at end of file diff --git a/.config/yazi/yazi.toml b/.config/yazi/yazi.toml index d360236..fdda9fe 100644 --- a/.config/yazi/yazi.toml +++ b/.config/yazi/yazi.toml @@ -14,23 +14,23 @@ show_symlink=true [opener] edit = [ - { exec = '$EDITOR "$@"', block = true, desc="Edit", for = "unix" }, + { run = '$EDITOR "$@"', block = true, desc="Edit", for = "unix" }, ] open = [ - { exec = 'xdg-open "$@"', desc = "Open", for = "linux" }, - { exec = 'open "$@"', desc = "Open", for = "macos" }, - { exec = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" } + { run = 'xdg-open "$@"', desc = "Open", for = "linux" }, + { run = 'open "$@"', desc = "Open", for = "macos" }, + { run = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" } ] extract = [ - { exec = '7z x "$1"', desc = "Extract here", for = "unix" }, + { run = '7z x "$1"', desc = "Extract here", for = "unix" }, ] play = [ - { exec = 'mpv "$@"', orphan = true, desc = "Play", for = "unix" }, - { exec = 'mpv "%1"', orphan = true, desc = "Play", for = "windows" }, + { run = 'mpv "$@"', orphan = true, desc = "Play", for = "unix" }, + { run = 'mpv "%1"', orphan = true, desc = "Play", for = "windows" }, ] info = [ - { exec = '''ffprobe -hide_banner "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show ffprobe info", for = "unix" }, - { exec = '''printf "'${1##*/}' Duration: ";ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show duration", for = "unix"} + { run = '''ffprobe -hide_banner "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show ffprobe info", for = "unix" }, + { run = '''printf "'${1##*/}' Duration: ";ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$1"; echo "Press enter to exit"; read''', block = true, desc = "Show duration", for = "unix"} ] [open] @@ -68,54 +68,54 @@ suppress_preload = false [plugin] prepend_previewers = [ - { name = "*.md", exec = "glow" }, + { name = "*.md", run = "glow" }, ] 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 = "viu" }, + { mime = "image/vnd.djvu", run = "noop" }, + { mime = "image/*", run = "viu" }, # Video - { mime = "video/*", exec = "video" }, + { mime = "video/*", run = "video" }, # PDF - { mime = "application/pdf", exec = "pdf2text" }, + { mime = "application/pdf", run = "pdf2text" }, # Archive - { mime = "application/zip", exec = "7z" }, - { mime = "application/gzip", exec = "7z" }, - { mime = "application/x-tar", exec = "7z" }, - { mime = "application/x-bzip", exec = "7z" }, - { mime = "application/x-bzip2", exec = "7z" }, - { mime = "application/x-7z-compressed", exec = "7z" }, - { mime = "application/x-rar", exec = "7z" }, - { mime = "application/xz", exec = "7z" }, - { mime = "application/x-bittorrent;", exec = "imdl" }, - { name = "*.torrent", exec = "imdl" }, + { mime = "application/zip", run = "7z" }, + { mime = "application/gzip", run = "7z" }, + { mime = "application/x-tar", run = "7z" }, + { mime = "application/x-bzip", run = "7z" }, + { mime = "application/x-bzip2", run = "7z" }, + { mime = "application/x-7z-compressed", run = "7z" }, + { mime = "application/x-rar", run = "7z" }, + { mime = "application/xz", run = "7z" }, + { mime = "application/x-bittorrent;", run = "imdl" }, + { name = "*.torrent", run = "imdl" }, # File Ext # Switch ROM - { name = "*.nsp", exec = "file" }, + { name = "*.nsp", run = "file" }, # Fallback - { mime = "application/octet-stream", exec = "hexyl" }, - { name = "*", exec = "file" }, + { mime = "application/octet-stream", run = "hexyl" }, + { name = "*", run = "file" }, ] [select] From 71ac4ef6b4d387ea2266273da2b4dfa788f446f4 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Thu, 14 Mar 2024 10:45:57 +0100 Subject: [PATCH 10/10] update yazi --- .config/yazi/init.lua | 82 ++++++++++++++-------------------------- .config/yazi/keymap.toml | 5 +++ 2 files changed, 33 insertions(+), 54 deletions(-) diff --git a/.config/yazi/init.lua b/.config/yazi/init.lua index da80ac1..f89c81a 100644 --- a/.config/yazi/init.lua +++ b/.config/yazi/init.lua @@ -1,35 +1,19 @@ -Manager = { - area = ui.Rect.default, -} - -function Manager:layout(area) - self.area = area - - return ui.Layout() - :direction(ui.Layout.HORIZONTAL) - :constraints({ - ui.Constraint.Ratio(MANAGER.ratio.parent, MANAGER.ratio.all), - ui.Constraint.Ratio(MANAGER.ratio.current, MANAGER.ratio.all), - ui.Constraint.Ratio(MANAGER.ratio.preview, MANAGER.ratio.all), - }) - :split(area) -end +-- Full Border function Manager:render(area) local chunks = self:layout(area) - local bar = function(c, x, y) - x, y = math.max(0, x), math.max(0, y) - return ui.Bar(ui.Rect { x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }, ui.Bar.TOP) - :symbol(c) - end + local bar = function(c, x, y) + x, y = math.max(0, x), math.max(0, y) + return ui.Bar(ui.Rect { x = x, y = y, w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) }, ui.Bar.TOP):symbol(c) + end return ya.flat { -- Borders ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED), ui.Bar(chunks[1], ui.Bar.RIGHT), ui.Bar(chunks[3], ui.Bar.LEFT), - + bar("┬", chunks[1].right - 1, chunks[1].y), bar("┴", chunks[1].right - 1, chunks[1].bottom - 1), bar("┬", chunks[2].right, chunks[2].y), @@ -44,23 +28,7 @@ function Manager:render(area) } end -function Header:host() - if ya.target_family() ~= "unix" then - return ui.Line {} - end - return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue") -end - -function Header:render(area) - local chunks = self:render(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 +-- Show owner in status bar function Status:owner() local h = cx.active.current.hovered @@ -76,28 +44,34 @@ function Status:owner() } end -function Status:mtime() - local h = cx.active.current.hovered - if h == nil or ya.target_family() ~= "unix" then - return ui.Line {} - end - - -- fix unix timestamp format - return ui.Line { - ui.Span(h.cha.modified):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:mtime(), self:owner(), self:percentage(), self:position() } - local right = ui.Line { self:owner(), self:percentage(), self:position() } + 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 + +-- Show hostname in header + +function Header:host() + if ya.target_family() ~= "unix" then + return ui.Line {} + end + return ui.Span(ya.user_name() .. "@" .. ya.host_name() .. ":"):fg("blue") +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())) } + return { + ui.Paragraph(area, { left }), + ui.Paragraph(area, { right }):align(ui.Paragraph.RIGHT), + } end \ No newline at end of file diff --git a/.config/yazi/keymap.toml b/.config/yazi/keymap.toml index ebd3893..45bd9d9 100644 --- a/.config/yazi/keymap.toml +++ b/.config/yazi/keymap.toml @@ -3,6 +3,11 @@ on = [ "" ] run = "close" desc = "Cancel input" +[[manager.prepend_keymap]] +on = [ "" ] +run = 'shell "$SHELL" --block --confirm' +desc = "Open shell here" + [[manager.prepend_keymap]] on = [ "l" ] run = "plugin --sync smart-enter"