Merge branch 'trunk' of github.com:bugabinga/dotfiles into trunk
e181aff30bc5ddcad345100f7bee86d59f092aa3
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
- Parent 1: c113505440b7 · Diff against parent 1
- Parent 2: d0f0e15107bc · Showing diff
bugabingas dorkfiles
e181aff30bc5ddcad345100f7bee86d59f092aa3
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
+1851 / −198 text lines · all files grouped into 32 bars
+2 / −0 text lines
deleted file mode 100644+0 / −19 text lines
deleted file mode 100644+0 / −133 text lines
# Don't ask for confirmations#assume_yes = true# Disable specific steps - same options as the command line flag#disable = ["system", "emacs"]# Ignore failures for these steps#ignore_failures = ["powershell"]# Run specific steps - same options as the command line flag#only = ["system", "emacs"]# Do not ask to retry failed steps (default: false)#no_retry = true# Sudo command to be used#sudo_command = "sudo"# Run `sudo -v` to cache credentials at the start of the run; this avoids a# blocking password prompt in the middle of a possibly-unattended run.#pre_sudo = false# Run inside tmux#run_in_tmux = true# List of remote machines with Topgrade installed on them#remote_topgrades = ["toothless", "pi", "parnas"]# Arguments to pass SSH when upgrading remote systems#ssh_arguments = "-o ConnectTimeout=2"# Path to Topgrade executable on remote machines#remote_topgrade_path = ".cargo/bin/topgrade"# Arguments to pass tmux when pulling Repositories#tmux_arguments = "-S /var/tmux.sock"# Do not set the terminal title#set_title = false# Display the time in step titles# display_time = true# Cleanup temporary or old files#cleanup = true# Skip sending a notification at the end of a run#skip_notify = true# Skip the preamble displayed when topgrade is run#display_preamble = false[git]#max_concurrency = 5# Additional git repositories to pull#repos = [# "~/src/*/",# "~/.config/something"#]# Don't pull the predefined git repos#pull_predefined = false# Arguments to pass Git when pulling Repositories#arguments = "--rebase --autostash"[composer]#self_update = true# Commands to run before anything[pre_commands]#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"# Custom commands[commands]#"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"[brew]#greedy_cask = true#autoremove = true[linux]# Arch Package Manager to use. Allowed values: autodetect, aura, garuda_update, pacman, pamac, paru, pikaur, trizen, yay.#arch_package_manager = "pacman"# Arguments to pass yay (or paru) when updating packages#yay_arguments = "--nodevel"# Arguments to pass dnf when updating packages#dnf_arguments = "--refresh"#aura_aur_arguments = "-kx"#aura_pacman_arguments = ""#garuda_update_arguments = ""#show_arch_news = true#trizen_arguments = "--devel"#pikaur_arguments = ""#pamac_arguments = "--no-devel"#enable_tlmgr = true#emerge_sync_flags = "-q"#emerge_update_flags = "-uDNa --with-bdeps=y world"#redhat_distro_sync = false#rpm_ostree = false#nix_arguments = "--flake"[python]#enable_pip_review = true ###disabled by default#enable_pipupgrade = true ###disabled by default[windows]# Manually select Windows updates#accept_all_updates = false#open_remotes_in_new_terminal = true#wsl_update_pre_release = true#wsl_update_use_web_download = true# Causes Topgrade to rename itself during the run to allow package managers# to upgrade it. Use this only if you installed Topgrade by using a package# manager such as Scoop or Cargo#self_rename = true[npm]# Use sudo if the NPM directory isn't owned by the current user#use_sudo = true[firmware]# Offer to update firmware; if false just check for and display available updates#upgrade = true[flatpak]# Use sudo for updating the system-wide installation#use_sudo = true[distrobox]#use_root = false#containers = ["archlinux-latest"]deleted file mode 100644+0 / −46 text lines
[misc]# Disable specific steps - same options as the command line flag# disable = ["system"]disable = ["vim"]assume_yes = true# Run specific steps - same options as the command line flag#only = ["system", "emacs"]# Do not ask to retry failed steps (default: false)no_retry = true# Do not set the terminal titleset_title = true# Display the time in step titlesdisplay_time = true# Cleanup temporary or old filescleanup = true[composer]self_update = true[git]# Additional git repositories to pullrepos = ["C:/Users/okr/Workspaces/*/"]max_concurrency = 12pull_predefined = false# Arguments to pass Git when pulling Repositories# arguments = "--ff --rebase"# Commands to run before anything[pre_commands]"01 - Winget Export" = "winget export --disable-interactivity --accept-source-agreements --output 'C:/Users/okr/Tools/winget_installed_apps.json' *> $null"[commands]"10 - Refresh dotfiles" = "java W:/dotfiles/bootstripper.java W:/dotfiles""20 - Install Cargo Tools" = "cd W:/dotfiles/tools ; java install.java""30 - Advantage-PM Client" = "nu X:/update_apm_client.nu""31 - MeMate" = "nu X:/update_memate.nu""40 - TLDR" = "tldr --update"new file mode 100644+27 / −0 text lines
local wez = require 'wezterm'-- Equivalent to POSIX basename(3)-- Given "/foo/bar" returns "bar"-- Given "c:\\foo\\bar" returns "bar"local function basename( s ) return string.gsub( s, '(.*[/\\])(.*)', '%2' )endlocal function tab_title( tab ) local title = tab.tab_title -- if the tab title is explicitly set, take that if title and #title > 0 then return title end local pane = tab.active_pane title = basename( pane.foreground_process_name ) local index = tab.tab_index + 1 return '・' .. index .. ' ' .. title .. ' 'endreturn function ( _ ) wez.on( 'format-tab-title', function ( tab ) return tab_title( tab ) end )endnew file mode 100644+3 / −0 text lines
new file mode 100644+19 / −0 text lines
[[manager.prepend_keymap]]on = ["C"]run = "plugin ouch --args=zip"desc = "Compress with ouch"[[manager.prepend_keymap]]on = [ "m" ]run = "plugin relative-motions"desc = "Trigger a new relative motion"[[manager.prepend_keymap]]on = "f"run = "plugin jump-to-char"desc = "Jump to char"[[manager.prepend_keymap]]on = "<C-d>"run = "plugin diff"desc = "Diff the selected with the hovered file"new file mode 100644+14 / −0 text lines
[plugin]deps = [ { use = "Tyarel8/video-ffmpeg", rev = "fe26a18" }, { use = "Reledia/hexyl", rev = "f845ea5" }, { use = "Sonico98/exifaudio", rev = "6205460" }, { use = "Reledia/miller", rev = "40e0265" }, { use = "dedukun/relative-motions", rev = "89d0cb9" }, { use = "yazi-rs/plugins:jump-to-char", rev = "c578505" }, { use = "yazi-rs/plugins:diff", rev = "c578505" }, { use = "yazi-rs/plugins:git", rev = "c578505" }][flavor]deps = []new file mode 100644No text changes.
new file mode 100644+21 / −0 text lines
MIT LicenseCopyright (c) 2023 yazi-rsPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.new file mode 100644+24 / −0 text lines
# diff.yaziDiff the selected file with the hovered file, create a living patch, and copy it to the clipboard.https://github.com/yazi-rs/plugins/assets/17523360/eff5e949-386a-44ea-82f9-4cb4a2c37aad## Installation```shya pack -a yazi-rs/plugins:diff```## UsageAdd this to your `~/.config/yazi/keymap.toml`:```toml[[manager.prepend_keymap]]on = "<C-d>"run = "plugin diff"desc = "Diff the selected with the hovered file"```Make sure the <kbd>C</kbd> + <kbd>d</kbd> key is not used elsewhere.new file mode 100644+37 / −0 text lines
local function info(content) return ya.notify { title = "Diff", content = content, timeout = 5, }endlocal selected_url = ya.sync(function() for _, u in pairs(cx.active.selected) do return u endend)local hovered_url = ya.sync(function() local h = cx.active.current.hovered return h and h.urlend)return { entry = function() local a, b = selected_url(), hovered_url() if not a then return info("No file selected") elseif not b then return info("No file hovered") end local output, err = Command("diff"):arg("-Naur"):arg(tostring(a)):arg(tostring(b)):output() if not output then return info("Failed to run diff, error: " .. err) end ya.clipboard(output.stdout) info("Diff copied to clipboard") end,}new file mode 100644No text changes.
new file mode 100644+21 / −0 text lines
MIT LicenseCopyright (c) 2024 Sonico98Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.new file mode 100644+38 / −0 text lines
# exifaudio.yaziPreview audio metadata and cover on [Yazi](https://github.com/sxyazi/yazi).## Installation```sh# Automatically with yazi 0.3.0ya pack -a "Sonico98/exifaudio"# Or manually under:# Linux/macOSgit clone https://github.com/Sonico98/exifaudio.yazi.git ~/.config/yazi/plugins/exifaudio.yazi# Windowsgit clone https://github.com/Sonico98/exifaudio.yazi.git %AppData%\yazi\config\plugins\exifaudio.yazi```## UsageAdd the following to your `yazi.toml`:```toml[plugin]prepend_previewers = [ { mime = "audio/*", run = "exifaudio"}]```Make sure you have [exiftool](https://exiftool.org/) installed and in your `PATH`.Optional: if you have [mediainfo](https://mediaarea.net/en/MediaInfo) installed and in your `PATH`, it will be used instead for more accurate metadata. Exiftool is still required to display the cover.## ThanksThanks to [sxyazi](https://github.com/sxyazi) for the PDF previewer code, on which this previewer is based on.new file mode 100644+215 / −0 text lines
local M = {}function GetPath(str) local sep = '/' if ya.target_family() == "windows" then sep = '\\' end return str:match("(.*"..sep..")")endfunction Exiftool(...) local child = Command("exiftool") :args({ "-q", "-q", "-S", "-Title", "-SortName", "-TitleSort", "-TitleSortOrder", "-Artist", "-SortArtist", "-ArtistSort", "-PerformerSortOrder", "-Album", "-SortAlbum", "-AlbumSort", "-AlbumSortOrder", "-AlbumArtist", "-SortAlbumArtist", "-AlbumArtistSort", "-AlbumArtistSortOrder", "-Genre", "-TrackNumber", "-Year", "-Duration", "-SampleRate", "-AudioSampleRate", "-AudioBitrate", "-AvgBitrate", "-Channels", "-AudioChannels", tostring(...), }) :stdout(Command.PIPED) :stderr(Command.NULL) :spawn() return childendfunction Mediainfo(...) local file, cache_dir = ... local template = cache_dir.."mediainfo.txt" local child = Command("mediainfo") :args({ "--Output=file://"..template, tostring(file) }) :stdout(Command.PIPED) :stderr(Command.NULL) :spawn() return childendfunction M:peek() local cache = ya.file_cache(self) if not cache then return end -- Get cache dir to find the mediainfo template file local cache_dir = GetPath(tostring(cache)) -- Try mediainfo, otherwise use exiftool local status, child = pcall(Mediainfo, self.file.url, cache_dir) if not status or child == nil then status, child = pcall(Exiftool, self.file.url) if not status or child == nil then local error = ui.Line { ui.Span("Make sure exiftool is installed and in your PATH") } local p = ui.Paragraph(self.area, { error }):wrap(ui.Paragraph.WRAP) ya.preview_widgets(self, { p }) return end end local limit = self.area.h local i, metadata = 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 local m_title, m_tag = Prettify(next) if m_title ~= "" and m_tag ~= "" then local ti = ui.Span(m_title):bold() local ta = ui.Span(m_tag) table.insert(metadata, ui.Line{ti, ta}) table.insert(metadata, ui.Line{}) end end until i >= self.skip + limit local p = ui.Paragraph(self.area, metadata):wrap(ui.Paragraph.WRAP) ya.preview_widgets(self, { p }) local cover_width = self.area.w / 2 - 5 local cover_height = (self.area.h / 4) + 3 local bottom_right = ui.Rect { x = self.area.right - cover_width, y = self.area.bottom - cover_height, w = cover_width, h = cover_height, } if self:preload() == 1 then ya.image_show(cache, bottom_right) endendfunction Prettify(metadata) local substitutions = { Sortname = "Sort Title:", SortName = "Sort Title:", TitleSort = "Sort Title:", TitleSortOrder = "Sort Title:", ArtistSort = "Sort Artist:", SortArtist = "Sort Artist:", Artist = "Artist:", ARTIST = "Artist:", PerformerSortOrder = "Sort Artist:", SortAlbumArtist = "Sort Album Artist:", AlbumArtistSortOrder = "Sort Album Artist:", AlbumArtistSort = "Sort Album Artist:", AlbumSortOrder = "Sort Album:", AlbumSort = "Sort Album:", SortAlbum = "Sort Album:", Album = "Album:", ALBUM = "Album:", AlbumArtist = "Album Artist:", Genre = "Genre:", GENRE = "Genre:", TrackNumber = "Track Number:", Year = "Year:", Duration = "Duration:", AudioBitrate = "Bitrate:", AvgBitrate = "Average Bitrate:", AudioSampleRate = "Sample Rate:", SampleRate = "Sample Rate:", AudioChannels = "Channels:" } for k, v in pairs(substitutions) do metadata = metadata:gsub(tostring(k)..":", v, 1) end -- Separate the tag title from the tag data local t={} for str in string.gmatch(metadata , "([^"..":".."]+)") do if str ~= "\n" then table.insert(t, str) else table.insert(t, nil) end end -- Add back semicolon to title, rejoin tag data if it happened to contain a semicolon local title, tag_data = "", "" if t[1] ~= nil then title, tag_data = t[1]..":", table.concat(t, ":", 2) end return title, tag_dataendfunction M:seek(units) local h = cx.active.current.hovered if h and h.url == self.file.url then ya.manager_emit("peek", { tostring(math.max(0, cx.active.preview.skip + units)), only_if = tostring(self.file.url), }) endendfunction M:preload() local cache = ya.file_cache(self) if not cache or fs.cha(cache) then return 1 end local mediainfo_template = 'General;"\$if(%Track%,Title: %Track%,)\$if(%Track/Sort%,Sort Title: %Track/Sort%,)\$if(%Title/Sort%,Sort Title: %Title/Sort%,)\$if(%TITLESORT%,Sort Title: %TITLESORT%,)\$if(%Performer%,Artist: %Performer%,)\$if(%Performer/Sort%,Sort Artist: %Performer/Sort%,)\$if(%ARTISTSORT%,Sort Artist: %ARTISTSORT%,)\$if(%Album%,Album: %Album%,)\$if(%Album/Sort%,Sort Album: %Album/Sort%)\$if(%ALBUMSORT%,Sort Album: %ALBUMSORT%)\$if(%Album/Performer%,Album Artist: %Album/Performer%)\$if(%Album/Performer/Sort%,Sort Album Artist: %Album/Performer/Sort%)\$if(%Genre%,Genre: %Genre%)\$if(%Track/Position%,Track Number: %Track/Position%)\$if(%Recorded_Date%,Year: %Recorded_Date%)\$if(%Duration/String%,Duration: %Duration/String%)\$if(%BitRate/String%,Bitrate: %BitRate/String%)\"\Audio;"Sample Rate: %SamplingRate%\Channels: %Channel(s)%"\' -- Write the mediainfo template file into yazi's cache dir local cache_dir = GetPath(tostring(cache)) fs.write(Url(cache_dir.."mediainfo.txt"), mediainfo_template) local output = Command("exiftool") :args({ "-b", "-CoverArt", "-Picture", tostring(self.file.url) }) :stdout(Command.PIPED) :stderr(Command.PIPED) :output() if not output then return 0 end return fs.write(cache, output.stdout) and 1 or 2endreturn Mnew file mode 100644No text changes.
new file mode 100644+21 / −0 text lines
MIT LicenseCopyright (c) 2023 yazi-rsPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.new file mode 100644+77 / −0 text lines
# git.yazi> [!NOTE]> Yazi v0.3.3 or later is required for this plugin to work.Show the status of Git file changes as linemode in the file list.https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576## Installation```shya pack -a yazi-rs/plugins:git```## SetupAdd the following to your `~/.config/yazi/init.lua`:```luarequire("git"):setup()```And register it as fetchers in your `~/.config/yazi/yazi.toml`:```toml[[plugin.prepend_fetchers]]id = "git"name = "*"run = "git"[[plugin.prepend_fetchers]]id = "git"name = "*/"run = "git"```## Advanced> [!NOTE]> This section currently requires Yazi nightly that includes https://github.com/sxyazi/yazi/pull/1637You can customize the [Style](https://yazi-rs.github.io/docs/plugins/layout#style) of the status sign with:- `THEME.git.modified`- `THEME.git.added`- `THEME.git.untracked`- `THEME.git.ignored`- `THEME.git.deleted`- `THEME.git.updated`For example:```lua-- ~/.config/yazi/init.luaTHEME.git = THEME.git or {}THEME.git.modified = ui.Style():fg("blue")THEME.git.deleted = ui.Style():fg("red"):bold()```You can also customize the text of the status sign with:- `THEME.git.modified_sign`- `THEME.git.added_sign`- `THEME.git.untracked_sign`- `THEME.git.ignored_sign`- `THEME.git.deleted_sign`- `THEME.git.updated_sign`For example:```lua-- ~/.config/yazi/init.luaTHEME.git = THEME.git or {}THEME.git.modified_sign = "M"THEME.git.deleted_sign = "D"```new file mode 100644+198 / −0 text lines
local WIN = ya.target_family() == "windows"local PATS = { { "[MT]", 6 }, -- Modified { "[AC]", 5 }, -- Added { "?$", 4 }, -- Untracked { "!$", 3 }, -- Ignored { "D", 2 }, -- Deleted { "U", 1 }, -- Updated { "[AD][AD]", 1 }, -- Updated}local function match(line) local signs = line:sub(1, 2) for _, p in ipairs(PATS) do local path if signs:find(p[1]) then path = line:sub(4, 4) == '"' and line:sub(5, -2) or line:sub(4) path = WIN and path:gsub("/", "\\") or path end if not path then elseif path:find("[/\\]$") then return p[2] == 3 and 30 or p[2], path:sub(1, -2) else return p[2], path end endendlocal function root(cwd) repeat local cha = fs.cha(cwd:join(".git")) if cha and cha.is_dir then return tostring(cwd) end cwd = cwd:parent() until not cwdendlocal function bubble_up(changed) local new, empty = {}, Url("") for k, v in pairs(changed) do if v ~= 3 and v ~= 30 then local url = Url(k):parent() while url and url ~= empty do local s = tostring(url) new[s] = (new[s] or 0) > v and new[s] or v url = url:parent() end end end return newendlocal function propagate_down(ignored, cwd, repo) local new, rel = {}, cwd:strip_prefix(repo) for k, v in pairs(ignored) do if v == 30 then if rel:starts_with(k) then new[tostring(repo:join(rel))] = 30 elseif cwd == repo:join(k):parent() then new[k] = 3 end end end return newendlocal add = ya.sync(function(st, cwd, repo, changed) st.dirs[cwd] = repo st.repos[repo] = st.repos[repo] or {} for k, v in pairs(changed) do if v == 0 then st.repos[repo][k] = nil elseif v == 30 then st.dirs[k] = "" else st.repos[repo][k] = v end end ya.render()end)local remove = ya.sync(function(st, cwd) local dir = st.dirs[cwd] if not dir then return end ya.render() st.dirs[cwd] = nil if not st.repos[dir] then return end for _, r in pairs(st.dirs) do if r == dir then return end end st.repos[dir] = nilend)local function setup(st, opts) st.dirs = {} st.repos = {} opts = opts or {} opts.order = opts.order or 1500 -- Chosen by ChatGPT fairly, PRs are welcome to adjust them local t = THEME.git or {} local styles = { [6] = t.modified and ui.Style(t.modified) or ui.Style():fg("#ffa500"), [5] = t.added and ui.Style(t.added) or ui.Style():fg("#32cd32"), [4] = t.untracked and ui.Style(t.untracked) or ui.Style():fg("#a9a9a9"), [3] = t.ignored and ui.Style(t.ignored) or ui.Style():fg("#696969"), [2] = t.deleted and ui.Style(t.deleted) or ui.Style():fg("#ff4500"), [1] = t.updated and ui.Style(t.updated) or ui.Style():fg("#1e90ff"), } local signs = { [6] = t.modified_sign and t.modified_sign or "", [5] = t.added_sign and t.added_sign or "", [4] = t.untracked_sign and t.untracked_sign or "", [3] = t.ignored_sign and t.ignored_sign or "", [2] = t.deleted_sign and t.deleted_sign or "", [1] = t.updated_sign and t.updated_sign or "U", } Linemode:children_add(function(self) local url = self._file.url local dir = st.dirs[tostring(url:parent())] local change if dir then change = dir == "" and 3 or st.repos[dir][tostring(url):sub(#dir + 2)] end if not change or signs[change] == "" then return ui.Line("") elseif self._file:is_hovered() then return ui.Line { ui.Span(" "), ui.Span(signs[change]) } else return ui.Line { ui.Span(" "), ui.Span(signs[change]):style(styles[change]) } end end, opts.order)endlocal function fetch(self) local cwd = self.files[1].url:parent() local repo = root(cwd) if not repo then remove(tostring(cwd)) return 1 end local paths = {} for _, f in ipairs(self.files) do paths[#paths + 1] = tostring(f.url) end -- stylua: ignore local output, err = Command("git") :cwd(tostring(cwd)) :args({ "--no-optional-locks", "-c", "core.quotePath=", "status", "--porcelain", "-unormal", "--no-renames", "--ignored=matching" }) :args(paths) :stdout(Command.PIPED) :output() if not output then ya.err("Cannot spawn git command, error code " .. tostring(err)) return 0 end local changed, ignored = {}, {} for line in output.stdout:gmatch("[^\r\n]+") do local sign, path = match(line) if sign == 30 then ignored[path] = sign else changed[path] = sign end end if self.files[1].cha.is_dir then ya.dict_merge(changed, bubble_up(changed)) ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo))) else ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo))) end for _, p in ipairs(paths) do local s = p:sub(#repo + 2) changed[s] = changed[s] or 0 end add(tostring(cwd), repo, changed) return 3endreturn { setup = setup, fetch = fetch }new file mode 100644No text changes.
new file mode 100644+7 / −0 text lines
Copyright © 2024 Reledia <reledia@prontonmail.com>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.new file mode 100644+22 / −0 text lines
# hexyl.yaziPreview any file on [Yazi](https://github.com/sxyazi/yazi) using [hexyl](https://github.com/sharkdp/hexyl). To install, use the `ya pack` cli utility:```bashya pack -a Reledia/hexyl```then include it in your `yazi.toml` to use:```toml[plugin]append_previewers = [ { name = "*", run = "hexyl" },]```Make sure you have [hexyl](https://github.com/sharkdp/hexyl) installed, and that can be found in `PATH`.## Previewnew file mode 100644+67 / −0 text lines
local M = {}function M:peek() local child local l = self.file.cha.length if l == 0 then child = Command("hexyl") :args({ tostring(self.file.url), }) :stdout(Command.PIPED) :stderr(Command.PIPED) :spawn() else child = Command("hexyl") :args({ "--border", "none", "--terminal-width", tostring(self.area.w), tostring(self.file.url), }) :stdout(Command.PIPED) :stderr(Command.PIPED) :spawn() end 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) }) endendfunction 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), }) endendreturn Mnew file mode 100644No text changes.
new file mode 100644+21 / −0 text lines
MIT LicenseCopyright (c) 2023 yazi-rsPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.new file mode 100644+24 / −0 text lines
# jump-to-char.yaziVim-like `f<char>`, jump to the next file whose name starts with `<char>`.https://github.com/yazi-rs/plugins/assets/17523360/aac9341c-b416-4e0c-aaba-889d48389869## Installation```shya pack -a yazi-rs/plugins:jump-to-char```## UsageAdd this to your `~/.config/yazi/keymap.toml`:```toml[[manager.prepend_keymap]]on = "f"run = "plugin jump-to-char"desc = "Jump to char"```Make sure the <kbd>f</kbd> key is not used elsewhere.new file mode 100644+30 / −0 text lines
local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."local changed = ya.sync(function(st, new) local b = st.last ~= new st.last = new return b or not cx.active.finderend)local escape = function(s) return s == "." and "\\." or s endreturn { entry = function() local cands = {} for i = 1, #AVAILABLE_CHARS do cands[#cands + 1] = { on = AVAILABLE_CHARS:sub(i, i) } end local idx = ya.which { cands = cands, silent = true } if not idx then return end local kw = escape(cands[idx].on) if changed(kw) then ya.manager_emit("find_do", { "^" .. kw }) else ya.manager_emit("find_arrow", {}) end end,}new file mode 100644No text changes.
new file mode 100644+7 / −0 text lines
Copyright © 2024 Reledia <reledia@prontonmail.com>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.new file mode 100644+27 / −0 text lines
# miller.yazi[Miller](https://github.com/johnkerl/miller) now in [yazi](https://github.com/sxyazi/yazi). To install, use the command `ya pack -a Reledia/miller` and add to your `yazi.toml`:```toml[plugin]prepend_previewers = [ { mime = "text/csv", run = "miller"},]```## Preview## ColorTo change colors of keys and values, edit the `init.lua` file after the `--key-color` and `--value-color` flags. To view a list of possible colors, use `mlr --list-color-names`. Make sure to have miller installed and inside your PATH.## Other types of fileTo adapt this plugin to the other format supported from miller (like json):- copy the plugin folder- change the name of the copied folder into miller\_(fmt)- change the `--icsv` flag inside `init.lua` to `--i(fmt)`- add the correct mime/name rule into `prepend_previewers` and the exec as `miller_(fmt)`new file mode 100644+59 / −0 text lines
local M = {}function M:peek() local child = Command("mlr") :args({ "--icsv", "--opprint", "-C", "--key-color", "darkcyan", "--value-color", "grey70", "cat", 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) }) endendfunction 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), }) endendreturn Mnew file mode 100644+21 / −0 text lines
MIT LicenseCopyright (c) 2024 ndtoan96Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THESOFTWARE.new file mode 100644+67 / −0 text lines
# ouch.yazi[ouch](https://github.com/ouch-org/ouch) plugin for [Yazi](https://github.com/sxyazi/yazi).## Features- Archive preview- Compression## Installation```bash# Linux/macOSgit clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi# Windowsgit clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi```Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.## Usage### PreviewFor archive preview, add this to your `yazi.toml`:```toml[plugin]prepend_previewers = [ # Archive previewer { mime = "application/*zip", run = "ouch" }, { mime = "application/x-tar", run = "ouch" }, { mime = "application/x-bzip2", run = "ouch" }, { mime = "application/x-7z-compressed", run = "ouch" }, { mime = "application/x-rar", run = "ouch" }, { mime = "application/x-xz", run = "ouch" },]```Now go to an archive on Yazi, you should see the archive's content in the preview pane. You can use `Alt-j` and `Alt-k` to roll up and down the preview.If you want to change the icon or the style of text, you can modify the `peek` function in `init.lua` file (all of them are stored in the `lines` variable).### CompressionFor compession, add this to your `keymap.toml`:```toml[[manager.prepend_keymap]]on = ["C"]run = "plugin ouch --args=zip"desc = "Compress with ouch"```The `--args=zip` part tells the plugin that default format is `zip`. You can change that to whatever format you want.### DecompressionThis plugin does not provide a decompression feature because it already is supported by Yazi.To decompress with `ouch`, configure the opener in `yazi.toml`.```toml[opener]extract = [ { run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" }, { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },]```new file mode 100644+143 / −0 text lines
local M = {}function M:peek() local child = Command("ouch") :args({ "l", "-t", "-y", tostring(self.file.url) }) :stdout(Command.PIPED) :stderr(Command.PIPED) :spawn() local limit = self.area.h local file_name = string.match(tostring(self.file.url), ".*[/\\](.*)") local lines = string.format("\x1b[2m📁 %s\x1b[0m\n", file_name) local num_lines = 1 local num_skip = 0 repeat local line, event = child:read_line() if event == 1 then ya.err(tostring(event)) elseif event ~= 0 then break end if line:find('Archive', 1, true) ~= 1 and line:find('[INFO]', 1, true) ~= 1 then if num_skip >= self.skip then lines = lines .. line num_lines = num_lines + 1 else num_skip = num_skip + 1 end end until num_lines >= limit child:start_kill() if self.skip > 0 and num_lines < limit then ya.manager_emit( "peek", { tostring(math.max(0, self.skip - (limit - num_lines))), only_if = tostring(self.file.url), upper_bound = "" } ) else ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) }) endendfunction 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", { math.max(0, cx.active.preview.skip + step), only_if = tostring(self.file.url), }) endend-- Check if file existslocal function file_exists(name) local f = io.open(name, "r") if f ~= nil then io.close(f) return true else return false endend-- Get the files that need to be compressed and infer a default archive namelocal get_compression_target = ya.sync(function() local tab = cx.active local default_name local paths = {} if #tab.selected == 0 then if tab.current.hovered then local name = tab.current.hovered.name default_name = name table.insert(paths, name) else return end else default_name = tab.current.cwd:name() for _, url in pairs(tab.selected) do table.insert(paths, tostring(url)) end -- The compression targets are aquired, now unselect them ya.manager_emit("escape", {}) end return paths, default_nameend)local function invoke_compress_command(paths, name) local cmd_output, err_code = Command("ouch") :args({ "c", "-y" }) :args(paths) :arg(name) :stderr(Command.PIPED) :output() if err_code ~= nil then ya.notify({ title = "Failed to run ouch command", content = "Status: " .. err_code, timeout = 5.0, level = "error", }) elseif not cmd_output.status.success then ya.notify({ title = "Compression failed: status code " .. cmd_output.status.code, content = cmd_output.stderr, timeout = 5.0, level = "error", }) endendfunction M:entry(args) local default_fmt = args[1] -- Get the files that need to be compressed and infer a default archive name local paths, default_name = get_compression_target() -- Get archive name from user local output_name, name_event = ya.input({ title = "Create archive:", value = default_name .. "." .. default_fmt, position = { "top-center", y = 3, w = 40 }, }) if name_event ~= 1 then return end -- Get confirmation if file exists if file_exists(output_name) then local confirm, confirm_event = ya.input({ title = "Overwrite " .. output_name .. "? (y/N)", position = { "top-center", y = 3, w = 40 }, }) if not (confirm_event == 1 and confirm:lower() == "y") then return end end invoke_compress_command(paths, output_name)endreturn Mnew file mode 100644No text changes.
new file mode 100644+19 / −0 text lines
Copyright (c) 2024 dedukunPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.new file mode 100644+142 / −0 text lines
# relative-motions.yaziA [Yazi](https://github.com/sxyazi/yazi) plugin based about vim motions.https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-442d-8d7b-2dccb6eee408## Requirements- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+## Installation```shya pack -a dedukun/relative-motions```## ConfigurationIf you want to use the numbers directly to start a motion add this to your `keymap.toml`:<details>```toml[[manager.prepend_keymap]]on = [ "1" ]run = "plugin relative-motions --args=1"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "2" ]run = "plugin relative-motions --args=2"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "3" ]run = "plugin relative-motions --args=3"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "4" ]run = "plugin relative-motions --args=4"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "5" ]run = "plugin relative-motions --args=5"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "6" ]run = "plugin relative-motions --args=6"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "7" ]run = "plugin relative-motions --args=7"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "8" ]run = "plugin relative-motions --args=8"desc = "Move in relative steps"[[manager.prepend_keymap]]on = [ "9" ]run = "plugin relative-motions --args=9"desc = "Move in relative steps"```</details>Alternatively you can use a key to trigger a new motion without any initial value, for that add the following in `keymap.toml`:```toml[[manager.prepend_keymap]]on = [ "m" ]run = "plugin relative-motions"desc = "Trigger a new relative motion"```---Additionally there are a couple of initial configurations that can be given to the plugin's `setup` function:| Configuration | Values | Default | Description || -------------- | ----------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- || `show_numbers` | `relative`, `absolute`, `relative_absolute` or `none` | `none` | Shows relative or absolute numbers before the file icon || `show_motion` | `true` or `false` | `false` | Shows current motion in Status bar || `only_motions` | `true` or `false` | `false` | If true, only the motion movements will be enabled, i.e., the commands for delete, cut, yank and visual selection will be disabled |If you want, for example, to enable relative numbers as well as to show the motion in the status bar,add the following to Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`:```lua-- ~/.config/yazi/init.luarequire("relative-motions"):setup({ show_numbers="relative", show_motion = true })```> [!NOTE]> The `show_numbers` and `show_motion` functionalities overwrite [`Current:render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/current.lua#L26)> and [`Status:children_render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/status.lua#L173) respectively.> If you have custom implementations for any of this functions> you can add the provided `Entity:number` and `Status:motion` to your implementations, just check [here](https://github.com/dedukun/relative-motions.yazi/blob/main/init.lua#L126) how we are doing things.## UsageThis plugin adds the some basic vim motions like `3k`, `12j`, `10gg`, etc.The following table show all the available motions:| Command | Description || -------------- | ------------------- || `j`/`<Down>` | Move `n` lines down || `k`/`<Up>` | Move `n` lines up || `gj`/`g<Down>` | Go `n` lines down || `gk`/`g<Up>` | Go `n` lines up || `gg` | Go to line |Furthermore, the following operations were also added:| Command | Description || ------- | ------------- || `v` | visual select || `y` | Yank || `x` | Cut || `d` | Delete motion |This however must be followed by a direction, which can be `j`/`<Down>`, `k`/`<Up>` or repeating the command key,which will operate from the cursor down, e.g. `2yy` will copy two files.Finally, we also support some tab operations:| Command | Description || ------- | ------------------------------------ || `t` | create `n` tabs || `H` | Move `n` tabs left || `L` | Move `n` tabs right || `gt` | Go to the `n` tab || `w` | Close tab `n` || `W` | Close `n` tabs right || `<` | Swap current tab with `n` tabs left || `>` | Swap current tab with `n` tabs right || `~` | Swap current tab with tab `n` |new file mode 100644+326 / −0 text lines
-- stylua: ignorelocal MOTIONS_AND_OP_KEYS = { { on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" }, { on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" }, -- commands { on = "d" }, { on = "v" }, { on = "y" }, { on = "x" }, -- tab commands { on = "t" }, { on = "L" }, { on = "H" }, { on = "w" }, { on = "W" }, { on = "<" }, { on = ">" }, { on = "~" }, -- movement { on = "g" }, { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" }}-- stylua: ignorelocal MOTION_KEYS = { { on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" }, { on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" }, -- movement { on = "g" }, { on = "j" }, { on = "k" }}-- stylua: ignorelocal DIRECTION_KEYS = { { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" }, -- tab movement { on = "t" }}local SHOW_NUMBERS_ABSOLUTE = 0local SHOW_NUMBERS_RELATIVE = 1local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2---------------------------------------------------------------- R E N D E R ----------------------------------------------------------------local render_motion_setup = ya.sync(function(_) ya.render() Status.motion = function() return ui.Span("") end Status.children_render = function(self, side) local lines = {} if side == self.RIGHT then lines[1] = self:motion(self) end for _, c in ipairs(side == self.RIGHT and self._right or self._left) do lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self) end return ui.Line(lines) end -- TODO: check why it doesn't work line this -- Status:children_add(Status.motion, 100, Status.RIGHT)end)local render_motion = ya.sync(function(_, motion_num, motion_cmd) ya.render() Status.motion = function(self) if not motion_num then return ui.Span("") end local style = self:style() local motion_span if not motion_cmd then motion_span = ui.Span(string.format(" %3d ", motion_num)):style(style) else motion_span = ui.Span(string.format(" %3d%s ", motion_num, motion_cmd)):style(style) end return ui.Line { ui.Span(THEME.status.separator_open):fg(style.bg), motion_span, ui.Span(THEME.status.separator_close):fg(style.bg), ui.Span(" "), } endend)local render_numbers = ya.sync(function(_, mode) ya.render() Entity.number = function(_, index, file, hovered) local idx if mode == SHOW_NUMBERS_RELATIVE then idx = math.abs(hovered - index) elseif mode == SHOW_NUMBERS_ABSOLUTE then idx = file.idx else -- SHOW_NUMBERS_RELATIVE_ABSOLUTE if hovered == index then idx = file.idx else idx = math.abs(hovered - index) end end -- emulate vim's hovered offset if idx >= 100 then return ui.Span(string.format("%4d ", idx)) elseif hovered == index then return ui.Span(string.format("%3d ", idx)) else return ui.Span(string.format(" %3d ", idx)) end end Current.render = function(self) local files = self._folder.window if #files == 0 then return self:empty() end local hovered_index for i, f in ipairs(files) do if f:is_hovered() then hovered_index = i break end end local entities, linemodes = {}, {} for i, f in ipairs(files) do linemodes[#linemodes + 1] = Linemode:new(f):render() local entity = Entity:new(f) entities[#entities + 1] = ui.ListItem(ui.Line { Entity:number(i, f, hovered_index), entity:render() }) :style(entity:style()) end return { ui.List(self._area, entities), ui.Paragraph(self._area, linemodes):align(ui.Paragraph.RIGHT), } endend)local function render_clear() render_motion() end-------------------------------------------------------- C O M M A N D P A R S E R --------------------------------------------------------local get_keys = ya.sync(function(state) return state._only_motions and MOTION_KEYS or MOTIONS_AND_OP_KEYS end)local function normal_direction(dir) if dir == "<Down>" then return "j" elseif dir == "<Up>" then return "k" end return direndlocal function get_cmd(first_char, keys) local last_key local lines = first_char or "" while true do render_motion(tonumber(lines)) local key = ya.which { cands = keys, silent = true } if not key then return nil, nil, nil end last_key = keys[key].on if not tonumber(last_key) then last_key = normal_direction(last_key) break end lines = lines .. last_key end render_motion(tonumber(lines), last_key) -- command direction local direction if last_key == "g" or last_key == "v" or last_key == "d" or last_key == "y" or last_key == "x" then DIRECTION_KEYS[#DIRECTION_KEYS + 1] = { on = last_key, } local direction_key = ya.which { cands = DIRECTION_KEYS, silent = true } if not direction_key then return nil, nil, nil end direction = DIRECTION_KEYS[direction_key].on direction = normal_direction(direction) end return tonumber(lines), last_key, directionendlocal function is_tab_command(command) local tab_commands = { "t", "L", "H", "w", "W", "<", ">", "~" } for _, cmd in ipairs(tab_commands) do if command == cmd then return true end end return falseendlocal get_active_tab = ya.sync(function(_) return cx.tabs.idx end)--------------------------------------------------------- E N T R Y / S E T U P ---------------------------------------------------------return { entry = function(_, args) local initial_value -- this is checking if the argument is a valid number if args then initial_value = tostring(tonumber(args[1])) if initial_value == "nil" then return end end local lines, cmd, direction = get_cmd(initial_value, get_keys()) if not lines or not cmd then -- command was cancelled render_clear() return end if cmd == "g" then if direction == "g" then ya.manager_emit("arrow", { -99999999 }) ya.manager_emit("arrow", { lines - 1 }) render_clear() return elseif direction == "j" then cmd = "j" elseif direction == "k" then cmd = "k" elseif direction == "t" then ya.manager_emit("tab_switch", { lines - 1 }) render_clear() return else -- no valid direction render_clear() return end end if cmd == "j" then ya.manager_emit("arrow", { lines }) elseif cmd == "k" then ya.manager_emit("arrow", { -lines }) elseif is_tab_command(cmd) then if cmd == "t" then for _ = 1, lines do ya.manager_emit("tab_create", {}) end elseif cmd == "H" then ya.manager_emit("tab_switch", { -lines, relative = true }) elseif cmd == "L" then ya.manager_emit("tab_switch", { lines, relative = true }) elseif cmd == "w" then ya.manager_emit("tab_close", { lines - 1 }) elseif cmd == "W" then local curr_tab = get_active_tab() local del_tab = curr_tab + lines - 1 for _ = curr_tab, del_tab do ya.manager_emit("tab_close", { curr_tab - 1 }) end ya.manager_emit("tab_switch", { curr_tab - 1 }) elseif cmd == "<" then ya.manager_emit("tab_swap", { -lines }) elseif cmd == ">" then ya.manager_emit("tab_swap", { lines }) elseif cmd == "~" then local jump = lines - get_active_tab() ya.manager_emit("tab_swap", { jump }) end else ya.manager_emit("visual_mode", {}) -- invert direction when user specifies it if direction == "k" then ya.manager_emit("arrow", { -lines }) elseif direction == "j" then ya.manager_emit("arrow", { lines }) else ya.manager_emit("arrow", { lines - 1 }) end ya.manager_emit("escape", {}) if cmd == "d" then ya.manager_emit("remove", {}) elseif cmd == "y" then ya.manager_emit("yank", {}) elseif cmd == "x" then ya.manager_emit("yank", { cut = true }) end end render_clear() end, setup = function(state, args) if not args then return end -- initialize state variables state._only_motions = args["only_motions"] or false if args["show_motion"] then render_motion_setup() end if args["show_numbers"] == "absolute" then render_numbers(SHOW_NUMBERS_ABSOLUTE) elseif args["show_numbers"] == "relative" then render_numbers(SHOW_NUMBERS_RELATIVE) elseif args["show_numbers"] == "relative_absolute" then render_numbers(SHOW_NUMBERS_RELATIVE_ABSOLUTE) end end,}new file mode 100644No text changes.
new file mode 100644+22 / −0 text lines
The MIT License (MIT)Copyright © 2024 Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the “Software”), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS INTHE SOFTWARE.No final newlinenew file mode 100644+29 / −0 text lines
# video-ffmpeg.yaziA plugin for [yazi](https://github.com/sxyazi/yazi) to preview videos without using [ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer) since I couldn't get it working for windows.## Requirements- `ffmpeg`## Installation```shya pack -a 'Tyarel8/video-ffmpeg'```## UsageAdd this to your `yazi.toml`:```toml[plugin]prepend_previewers = [ { mime = "video/*", run = "video-ffmpeg" },]prepend_preloaders = [ { mime = "video/*", run = "video-ffmpeg" },]```new file mode 100644+70 / −0 text lines
local M = {}function M:peek() local start, cache = os.clock(), ya.file_cache(self) if not cache or self:preload() ~= 1 then return end ya.sleep(math.max(0, PREVIEW.image_delay / 1000 + start - os.clock())) ya.image_show(cache, self.area) ya.preview_widgets(self, {})endfunction M:seek(units) local h = cx.active.current.hovered if h and h.url == self.file.url then ya.manager_emit("peek", { math.max(0, cx.active.preview.skip + units), only_if = self.file.url, }) endendfunction M:preload() local percentage = 5 + self.skip if percentage > 95 then ya.manager_emit("peek", { 90, only_if = self.file.url, upper_bound = true }) return 2 end local cache = ya.file_cache(self) if not cache or fs.cha(cache) then return 1 end -- Get the video duration in seconds local probe = Command("ffprobe"):args({ "-i", tostring(self.file.url), "-show_entries", "format=duration", "-v", "quiet", "-of", "csv=p=0" }):stdout(Command.PIPED):output() -- Calculate second to take thumbnail local sec = tonumber(probe.stdout) * percentage / 100 local child, code = Command("ffmpeg"):args({ "-ss", -- Replace `,` with `.` to prevent locale issues where the decimal separator is `,` tostring(sec):gsub(",", "."), "-i", tostring(self.file.url), "-vf", "scale=" .. tostring(PREVIEW.max_width) .. ":-1", "-q:v", "6", "-frames:v", "1", "-f", "image2", tostring(cache), }):spawn() if not child then ya.err("spawn `ffmpeg` command returns " .. tostring(code)) return 0 end local status = child:wait() return status and status.success and 1 or 2endreturn Mnew file mode 100644+31 / −0 text lines
[plugin]prepend_previewers = [ { mime = "video/*", run = "video-ffmpeg" }, { mime = "audio/*", run = "exifaudio" }, { mime = "text/csv", run = "miller" }, { mime = "application/*zip", run = "ouch" }, { mime = "application/x-tar", run = "ouch" }, { mime = "application/x-bzip2", run = "ouch" }, { mime = "application/x-7z-compressed", run = "ouch" }, { mime = "application/x-rar", run = "ouch" }, { mime = "application/x-xz", run = "ouch" },]append_previewers = [ { name = "*", run = "hexyl" },]prepend_preloaders = [ { mime = "video/*", run = "video-ffmpeg" }][opener]extract = [ { run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" }, { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },][[plugin.prepend_fetchers]]id = "git"name = "*"run = "git"