repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

yazi: adds yazi config

c03e4271fe98fc7985c32b12810519e52153b1b4

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (38)

wezterm/bugabinga/titles.lua

Added
new file mode 100644
1 +local wez = require 'wezterm'
3 +-- Equivalent to POSIX basename(3)
4 +-- Given "/foo/bar" returns "bar"
5 +-- Given "c:\\foo\\bar" returns "bar"
6 +local function basename( s )
7 + return string.gsub( s, '(.*[/\\])(.*)', '%2' )
8 +end
10 +local function tab_title( tab )
11 + local title = tab.tab_title
12 + -- if the tab title is explicitly set, take that
13 + if title and #title > 0 then
14 + return title
15 + end
16 + local pane = tab.active_pane
17 + title = basename( pane.foreground_process_name )
18 + local index = tab.tab_index + 1
19 + return '・' .. index .. ' ' .. title .. ' '
20 +end
22 +return function ( _ )
23 + wez.on(
24 + 'format-tab-title',
25 + function ( tab ) return tab_title( tab ) end
26 + )
27 +end

yazi/init.lua

Added
new file mode 100644
1 +require("relative-motions"):setup({ show_numbers="relative", show_motion = true })
3 +require("git"):setup()

yazi/keymap.toml

Added
new file mode 100644
1 +[[manager.prepend_keymap]]
2 +on = ["C"]
3 +run = "plugin ouch --args=zip"
4 +desc = "Compress with ouch"
6 +[[manager.prepend_keymap]]
7 +on = [ "m" ]
8 +run = "plugin relative-motions"
9 +desc = "Trigger a new relative motion"
11 +[[manager.prepend_keymap]]
12 +on = "f"
13 +run = "plugin jump-to-char"
14 +desc = "Jump to char"
16 +[[manager.prepend_keymap]]
17 +on = "<C-d>"
18 +run = "plugin diff"
19 +desc = "Diff the selected with the hovered file"

yazi/package.toml

Added
new file mode 100644
1 +[plugin]
2 +deps = [
3 + { use = "Tyarel8/video-ffmpeg", rev = "fe26a18" },
4 + { use = "Reledia/hexyl", rev = "f845ea5" },
5 + { use = "Sonico98/exifaudio", rev = "6205460" },
6 + { use = "Reledia/miller", rev = "40e0265" },
7 + { use = "dedukun/relative-motions", rev = "89d0cb9" },
8 + { use = "yazi-rs/plugins:jump-to-char", rev = "c578505" },
9 + { use = "yazi-rs/plugins:diff", rev = "c578505" },
10 + { use = "yazi-rs/plugins:git", rev = "c578505" }
13 +[flavor]
14 +deps = []

yazi/plugins/diff.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/diff.yazi/LICENSE

Added
new file mode 100644
1 +MIT License
3 +Copyright (c) 2023 yazi-rs
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.

yazi/plugins/diff.yazi/README.md

Added
new file mode 100644
1 +# diff.yazi
3 +Diff the selected file with the hovered file, create a living patch, and copy it to the clipboard.
5 +https://github.com/yazi-rs/plugins/assets/17523360/eff5e949-386a-44ea-82f9-4cb4a2c37aad
7 +## Installation
9 +```sh
10 +ya pack -a yazi-rs/plugins:diff
11 +```
13 +## Usage
15 +Add this to your `~/.config/yazi/keymap.toml`:
17 +```toml
18 +[[manager.prepend_keymap]]
19 +on = "<C-d>"
20 +run = "plugin diff"
21 +desc = "Diff the selected with the hovered file"
22 +```
24 +Make sure the <kbd>C</kbd> + <kbd>d</kbd> key is not used elsewhere.

yazi/plugins/diff.yazi/init.lua

Added
new file mode 100644
1 +local function info(content)
2 + return ya.notify {
3 + title = "Diff",
4 + content = content,
5 + timeout = 5,
6 + }
7 +end
9 +local selected_url = ya.sync(function()
10 + for _, u in pairs(cx.active.selected) do
11 + return u
12 + end
13 +end)
15 +local hovered_url = ya.sync(function()
16 + local h = cx.active.current.hovered
17 + return h and h.url
18 +end)
20 +return {
21 + entry = function()
22 + local a, b = selected_url(), hovered_url()
23 + if not a then
24 + return info("No file selected")
25 + elseif not b then
26 + return info("No file hovered")
27 + end
29 + local output, err = Command("diff"):arg("-Naur"):arg(tostring(a)):arg(tostring(b)):output()
30 + if not output then
31 + return info("Failed to run diff, error: " .. err)
32 + end
34 + ya.clipboard(output.stdout)
35 + info("Diff copied to clipboard")
36 + end,

yazi/plugins/exifaudio.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/exifaudio.yazi/LICENSE

Added
new file mode 100644
1 +MIT License
3 +Copyright (c) 2024 Sonico98
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.

yazi/plugins/exifaudio.yazi/README.md

Added
new file mode 100644
1 +# exifaudio.yazi
3 +Preview audio metadata and cover on [Yazi](https://github.com/sxyazi/yazi).
5 +![image](https://github.com/Sonico98/exifaudio.yazi/assets/61394886/53c1492c-9f05-4c80-a4e7-94fb36f35ca9)
7 +## Installation
9 +```sh
10 +# Automatically with yazi 0.3.0
11 +ya pack -a "Sonico98/exifaudio"
13 +# Or manually under:
14 +# Linux/macOS
15 +git clone https://github.com/Sonico98/exifaudio.yazi.git ~/.config/yazi/plugins/exifaudio.yazi
17 +# Windows
18 +git clone https://github.com/Sonico98/exifaudio.yazi.git %AppData%\yazi\config\plugins\exifaudio.yazi
19 +```
21 +## Usage
23 +Add the following to your `yazi.toml`:
25 +```toml
26 +[plugin]
27 +prepend_previewers = [
28 + { mime = "audio/*", run = "exifaudio"}
30 +```
32 +Make sure you have [exiftool](https://exiftool.org/) installed and in your `PATH`.
34 +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.
36 +## Thanks
38 +Thanks to [sxyazi](https://github.com/sxyazi) for the PDF previewer code, on which this previewer is based on.

yazi/plugins/exifaudio.yazi/init.lua

Added
new file mode 100644
1 +local M = {}
3 +function GetPath(str)
4 + local sep = '/'
5 + if ya.target_family() == "windows" then
6 + sep = '\\'
7 + end
8 + return str:match("(.*"..sep..")")
9 +end
11 +function Exiftool(...)
12 + local child = Command("exiftool")
13 + :args({
14 + "-q", "-q", "-S", "-Title", "-SortName",
15 + "-TitleSort", "-TitleSortOrder", "-Artist",
16 + "-SortArtist", "-ArtistSort", "-PerformerSortOrder",
17 + "-Album", "-SortAlbum", "-AlbumSort", "-AlbumSortOrder",
18 + "-AlbumArtist", "-SortAlbumArtist", "-AlbumArtistSort",
19 + "-AlbumArtistSortOrder", "-Genre", "-TrackNumber",
20 + "-Year", "-Duration", "-SampleRate",
21 + "-AudioSampleRate", "-AudioBitrate", "-AvgBitrate",
22 + "-Channels", "-AudioChannels", tostring(...),
23 + })
24 + :stdout(Command.PIPED)
25 + :stderr(Command.NULL)
26 + :spawn()
27 + return child
28 +end
30 +function Mediainfo(...)
31 + local file, cache_dir = ...
32 + local template = cache_dir.."mediainfo.txt"
33 + local child = Command("mediainfo")
34 + :args({
35 + "--Output=file://"..template, tostring(file)
36 + })
37 + :stdout(Command.PIPED)
38 + :stderr(Command.NULL)
39 + :spawn()
40 + return child
41 +end
43 +function M:peek()
44 + local cache = ya.file_cache(self)
45 + if not cache then
46 + return
47 + end
49 + -- Get cache dir to find the mediainfo template file
50 + local cache_dir = GetPath(tostring(cache))
52 + -- Try mediainfo, otherwise use exiftool
53 + local status, child = pcall(Mediainfo, self.file.url, cache_dir)
54 + if not status or child == nil then
55 + status, child = pcall(Exiftool, self.file.url)
56 + if not status or child == nil then
57 + local error = ui.Line { ui.Span("Make sure exiftool is installed and in your PATH") }
58 + local p = ui.Paragraph(self.area, { error }):wrap(ui.Paragraph.WRAP)
59 + ya.preview_widgets(self, { p })
60 + return
61 + end
62 + end
64 + local limit = self.area.h
65 + local i, metadata = 0, {}
66 + repeat
67 + local next, event = child:read_line()
68 + if event == 1 then
69 + return self:fallback_to_builtin()
70 + elseif event ~= 0 then
71 + break
72 + end
74 + i = i + 1
75 + if i > self.skip then
76 + local m_title, m_tag = Prettify(next)
77 + if m_title ~= "" and m_tag ~= "" then
78 + local ti = ui.Span(m_title):bold()
79 + local ta = ui.Span(m_tag)
80 + table.insert(metadata, ui.Line{ti, ta})
81 + table.insert(metadata, ui.Line{})
82 + end
83 + end
84 + until i >= self.skip + limit
86 + local p = ui.Paragraph(self.area, metadata):wrap(ui.Paragraph.WRAP)
87 + ya.preview_widgets(self, { p })
89 + local cover_width = self.area.w / 2 - 5
90 + local cover_height = (self.area.h / 4) + 3
92 + local bottom_right = ui.Rect {
93 + x = self.area.right - cover_width,
94 + y = self.area.bottom - cover_height,
95 + w = cover_width,
96 + h = cover_height,
97 + }
99 + if self:preload() == 1 then
100 + ya.image_show(cache, bottom_right)
101 + end
102 +end
104 +function Prettify(metadata)
105 + local substitutions = {
106 + Sortname = "Sort Title:",
107 + SortName = "Sort Title:",
108 + TitleSort = "Sort Title:",
109 + TitleSortOrder = "Sort Title:",
110 + ArtistSort = "Sort Artist:",
111 + SortArtist = "Sort Artist:",
112 + Artist = "Artist:",
113 + ARTIST = "Artist:",
114 + PerformerSortOrder = "Sort Artist:",
115 + SortAlbumArtist = "Sort Album Artist:",
116 + AlbumArtistSortOrder = "Sort Album Artist:",
117 + AlbumArtistSort = "Sort Album Artist:",
118 + AlbumSortOrder = "Sort Album:",
119 + AlbumSort = "Sort Album:",
120 + SortAlbum = "Sort Album:",
121 + Album = "Album:",
122 + ALBUM = "Album:",
123 + AlbumArtist = "Album Artist:",
124 + Genre = "Genre:",
125 + GENRE = "Genre:",
126 + TrackNumber = "Track Number:",
127 + Year = "Year:",
128 + Duration = "Duration:",
129 + AudioBitrate = "Bitrate:",
130 + AvgBitrate = "Average Bitrate:",
131 + AudioSampleRate = "Sample Rate:",
132 + SampleRate = "Sample Rate:",
133 + AudioChannels = "Channels:"
136 + for k, v in pairs(substitutions) do
137 + metadata = metadata:gsub(tostring(k)..":", v, 1)
138 + end
140 + -- Separate the tag title from the tag data
141 + local t={}
142 + for str in string.gmatch(metadata , "([^"..":".."]+)") do
143 + if str ~= "\n" then
144 + table.insert(t, str)
145 + else
146 + table.insert(t, nil)
147 + end
148 + end
150 + -- Add back semicolon to title, rejoin tag data if it happened to contain a semicolon
151 + local title, tag_data = "", ""
152 + if t[1] ~= nil then
153 + title, tag_data = t[1]..":", table.concat(t, ":", 2)
154 + end
155 + return title, tag_data
157 +end
159 +function M:seek(units)
160 + local h = cx.active.current.hovered
161 + if h and h.url == self.file.url then
162 + ya.manager_emit("peek", {
163 + tostring(math.max(0, cx.active.preview.skip + units)),
164 + only_if = tostring(self.file.url),
165 + })
166 + end
167 +end
169 +function M:preload()
170 + local cache = ya.file_cache(self)
171 + if not cache or fs.cha(cache) then
172 + return 1
173 + end
175 + local mediainfo_template = 'General;"\
176 +$if(%Track%,Title: %Track%,)\
177 +$if(%Track/Sort%,Sort Title: %Track/Sort%,)\
178 +$if(%Title/Sort%,Sort Title: %Title/Sort%,)\
179 +$if(%TITLESORT%,Sort Title: %TITLESORT%,)\
180 +$if(%Performer%,Artist: %Performer%,)\
181 +$if(%Performer/Sort%,Sort Artist: %Performer/Sort%,)\
182 +$if(%ARTISTSORT%,Sort Artist: %ARTISTSORT%,)\
183 +$if(%Album%,Album: %Album%,)\
184 +$if(%Album/Sort%,Sort Album: %Album/Sort%)\
185 +$if(%ALBUMSORT%,Sort Album: %ALBUMSORT%)\
186 +$if(%Album/Performer%,Album Artist: %Album/Performer%)\
187 +$if(%Album/Performer/Sort%,Sort Album Artist: %Album/Performer/Sort%)\
188 +$if(%Genre%,Genre: %Genre%)\
189 +$if(%Track/Position%,Track Number: %Track/Position%)\
190 +$if(%Recorded_Date%,Year: %Recorded_Date%)\
191 +$if(%Duration/String%,Duration: %Duration/String%)\
192 +$if(%BitRate/String%,Bitrate: %BitRate/String%)\
194 +Audio;"Sample Rate: %SamplingRate%\
195 +Channels: %Channel(s)%"\
198 + -- Write the mediainfo template file into yazi's cache dir
199 + local cache_dir = GetPath(tostring(cache))
200 + fs.write(Url(cache_dir.."mediainfo.txt"), mediainfo_template)
202 + local output = Command("exiftool")
203 + :args({ "-b", "-CoverArt", "-Picture", tostring(self.file.url) })
204 + :stdout(Command.PIPED)
205 + :stderr(Command.PIPED)
206 + :output()
208 + if not output then
209 + return 0
210 + end
212 + return fs.write(cache, output.stdout) and 1 or 2
213 +end
215 +return M

yazi/plugins/git.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/git.yazi/LICENSE

Added
new file mode 100644
1 +MIT License
3 +Copyright (c) 2023 yazi-rs
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.

yazi/plugins/git.yazi/README.md

Added
new file mode 100644
1 +# git.yazi
3 +> [!NOTE]
4 +> Yazi v0.3.3 or later is required for this plugin to work.
6 +Show the status of Git file changes as linemode in the file list.
8 +https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576
10 +## Installation
12 +```sh
13 +ya pack -a yazi-rs/plugins:git
14 +```
16 +## Setup
18 +Add the following to your `~/.config/yazi/init.lua`:
20 +```lua
21 +require("git"):setup()
22 +```
24 +And register it as fetchers in your `~/.config/yazi/yazi.toml`:
26 +```toml
27 +[[plugin.prepend_fetchers]]
28 +id = "git"
29 +name = "*"
30 +run = "git"
32 +[[plugin.prepend_fetchers]]
33 +id = "git"
34 +name = "*/"
35 +run = "git"
36 +```
38 +## Advanced
40 +> [!NOTE]
41 +> This section currently requires Yazi nightly that includes https://github.com/sxyazi/yazi/pull/1637
43 +You can customize the [Style](https://yazi-rs.github.io/docs/plugins/layout#style) of the status sign with:
45 +- `THEME.git.modified`
46 +- `THEME.git.added`
47 +- `THEME.git.untracked`
48 +- `THEME.git.ignored`
49 +- `THEME.git.deleted`
50 +- `THEME.git.updated`
52 +For example:
54 +```lua
55 +-- ~/.config/yazi/init.lua
56 +THEME.git = THEME.git or {}
57 +THEME.git.modified = ui.Style():fg("blue")
58 +THEME.git.deleted = ui.Style():fg("red"):bold()
59 +```
61 +You can also customize the text of the status sign with:
63 +- `THEME.git.modified_sign`
64 +- `THEME.git.added_sign`
65 +- `THEME.git.untracked_sign`
66 +- `THEME.git.ignored_sign`
67 +- `THEME.git.deleted_sign`
68 +- `THEME.git.updated_sign`
70 +For example:
72 +```lua
73 +-- ~/.config/yazi/init.lua
74 +THEME.git = THEME.git or {}
75 +THEME.git.modified_sign = "M"
76 +THEME.git.deleted_sign = "D"
77 +```

yazi/plugins/git.yazi/init.lua

Added
new file mode 100644
1 +local WIN = ya.target_family() == "windows"
2 +local PATS = {
3 + { "[MT]", 6 }, -- Modified
4 + { "[AC]", 5 }, -- Added
5 + { "?$", 4 }, -- Untracked
6 + { "!$", 3 }, -- Ignored
7 + { "D", 2 }, -- Deleted
8 + { "U", 1 }, -- Updated
9 + { "[AD][AD]", 1 }, -- Updated
12 +local function match(line)
13 + local signs = line:sub(1, 2)
14 + for _, p in ipairs(PATS) do
15 + local path
16 + if signs:find(p[1]) then
17 + path = line:sub(4, 4) == '"' and line:sub(5, -2) or line:sub(4)
18 + path = WIN and path:gsub("/", "\\") or path
19 + end
20 + if not path then
21 + elseif path:find("[/\\]$") then
22 + return p[2] == 3 and 30 or p[2], path:sub(1, -2)
23 + else
24 + return p[2], path
25 + end
26 + end
27 +end
29 +local function root(cwd)
30 + repeat
31 + local cha = fs.cha(cwd:join(".git"))
32 + if cha and cha.is_dir then
33 + return tostring(cwd)
34 + end
35 + cwd = cwd:parent()
36 + until not cwd
37 +end
39 +local function bubble_up(changed)
40 + local new, empty = {}, Url("")
41 + for k, v in pairs(changed) do
42 + if v ~= 3 and v ~= 30 then
43 + local url = Url(k):parent()
44 + while url and url ~= empty do
45 + local s = tostring(url)
46 + new[s] = (new[s] or 0) > v and new[s] or v
47 + url = url:parent()
48 + end
49 + end
50 + end
51 + return new
52 +end
54 +local function propagate_down(ignored, cwd, repo)
55 + local new, rel = {}, cwd:strip_prefix(repo)
56 + for k, v in pairs(ignored) do
57 + if v == 30 then
58 + if rel:starts_with(k) then
59 + new[tostring(repo:join(rel))] = 30
60 + elseif cwd == repo:join(k):parent() then
61 + new[k] = 3
62 + end
63 + end
64 + end
65 + return new
66 +end
68 +local add = ya.sync(function(st, cwd, repo, changed)
69 + st.dirs[cwd] = repo
70 + st.repos[repo] = st.repos[repo] or {}
71 + for k, v in pairs(changed) do
72 + if v == 0 then
73 + st.repos[repo][k] = nil
74 + elseif v == 30 then
75 + st.dirs[k] = ""
76 + else
77 + st.repos[repo][k] = v
78 + end
79 + end
80 + ya.render()
81 +end)
83 +local remove = ya.sync(function(st, cwd)
84 + local dir = st.dirs[cwd]
85 + if not dir then
86 + return
87 + end
89 + ya.render()
90 + st.dirs[cwd] = nil
91 + if not st.repos[dir] then
92 + return
93 + end
95 + for _, r in pairs(st.dirs) do
96 + if r == dir then
97 + return
98 + end
99 + end
100 + st.repos[dir] = nil
101 +end)
103 +local function setup(st, opts)
104 + st.dirs = {}
105 + st.repos = {}
107 + opts = opts or {}
108 + opts.order = opts.order or 1500
110 + -- Chosen by ChatGPT fairly, PRs are welcome to adjust them
111 + local t = THEME.git or {}
112 + local styles = {
113 + [6] = t.modified and ui.Style(t.modified) or ui.Style():fg("#ffa500"),
114 + [5] = t.added and ui.Style(t.added) or ui.Style():fg("#32cd32"),
115 + [4] = t.untracked and ui.Style(t.untracked) or ui.Style():fg("#a9a9a9"),
116 + [3] = t.ignored and ui.Style(t.ignored) or ui.Style():fg("#696969"),
117 + [2] = t.deleted and ui.Style(t.deleted) or ui.Style():fg("#ff4500"),
118 + [1] = t.updated and ui.Style(t.updated) or ui.Style():fg("#1e90ff"),
120 + local signs = {
121 + [6] = t.modified_sign and t.modified_sign or "",
122 + [5] = t.added_sign and t.added_sign or "",
123 + [4] = t.untracked_sign and t.untracked_sign or "",
124 + [3] = t.ignored_sign and t.ignored_sign or "",
125 + [2] = t.deleted_sign and t.deleted_sign or "",
126 + [1] = t.updated_sign and t.updated_sign or "U",
129 + Linemode:children_add(function(self)
130 + local url = self._file.url
131 + local dir = st.dirs[tostring(url:parent())]
132 + local change
133 + if dir then
134 + change = dir == "" and 3 or st.repos[dir][tostring(url):sub(#dir + 2)]
135 + end
137 + if not change or signs[change] == "" then
138 + return ui.Line("")
139 + elseif self._file:is_hovered() then
140 + return ui.Line { ui.Span(" "), ui.Span(signs[change]) }
141 + else
142 + return ui.Line { ui.Span(" "), ui.Span(signs[change]):style(styles[change]) }
143 + end
144 + end, opts.order)
145 +end
147 +local function fetch(self)
148 + local cwd = self.files[1].url:parent()
149 + local repo = root(cwd)
150 + if not repo then
151 + remove(tostring(cwd))
152 + return 1
153 + end
155 + local paths = {}
156 + for _, f in ipairs(self.files) do
157 + paths[#paths + 1] = tostring(f.url)
158 + end
160 + -- stylua: ignore
161 + local output, err = Command("git")
162 + :cwd(tostring(cwd))
163 + :args({ "--no-optional-locks", "-c", "core.quotePath=", "status", "--porcelain", "-unormal", "--no-renames", "--ignored=matching" })
164 + :args(paths)
165 + :stdout(Command.PIPED)
166 + :output()
167 + if not output then
168 + ya.err("Cannot spawn git command, error code " .. tostring(err))
169 + return 0
170 + end
172 + local changed, ignored = {}, {}
173 + for line in output.stdout:gmatch("[^\r\n]+") do
174 + local sign, path = match(line)
175 + if sign == 30 then
176 + ignored[path] = sign
177 + else
178 + changed[path] = sign
179 + end
180 + end
182 + if self.files[1].cha.is_dir then
183 + ya.dict_merge(changed, bubble_up(changed))
184 + ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
185 + else
186 + ya.dict_merge(changed, propagate_down(ignored, cwd, Url(repo)))
187 + end
189 + for _, p in ipairs(paths) do
190 + local s = p:sub(#repo + 2)
191 + changed[s] = changed[s] or 0
192 + end
193 + add(tostring(cwd), repo, changed)
195 + return 3
196 +end
198 +return { setup = setup, fetch = fetch }

yazi/plugins/hexyl.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/hexyl.yazi/LICENSE

Added
new file mode 100644
1 +Copyright © 2024 Reledia <reledia@prontonmail.com>
3 +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:
5 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 +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.

yazi/plugins/hexyl.yazi/README.md

Added
new file mode 100644
1 +# hexyl.yazi
3 +Preview any file on [Yazi](https://github.com/sxyazi/yazi) using [hexyl](https://github.com/sharkdp/hexyl). To install, use the `ya pack` cli utility:
5 +```bash
6 +ya pack -a Reledia/hexyl
7 +```
9 +then include it in your `yazi.toml` to use:
11 +```toml
12 +[plugin]
13 +append_previewers = [
14 + { name = "*", run = "hexyl" },
16 +```
18 +Make sure you have [hexyl](https://github.com/sharkdp/hexyl) installed, and that can be found in `PATH`.
20 +## Preview
22 +![preview.png](https://raw.githubusercontent.com/Reledia/hexyl.yazi/main/image.png)

yazi/plugins/hexyl.yazi/init.lua

Added
new file mode 100644
1 +local M = {}
3 +function M:peek()
4 + local child
5 + local l = self.file.cha.length
6 + if l == 0 then
7 + child = Command("hexyl")
8 + :args({
9 + tostring(self.file.url),
10 + })
11 + :stdout(Command.PIPED)
12 + :stderr(Command.PIPED)
13 + :spawn()
14 + else
15 + child = Command("hexyl")
16 + :args({
17 + "--border",
18 + "none",
19 + "--terminal-width",
20 + tostring(self.area.w),
21 + tostring(self.file.url),
22 + })
23 + :stdout(Command.PIPED)
24 + :stderr(Command.PIPED)
25 + :spawn()
26 + end
28 + local limit = self.area.h
29 + local i, lines = 0, ""
30 + repeat
31 + local next, event = child:read_line()
32 + if event == 1 then
33 + ya.err(tostring(event))
34 + elseif event ~= 0 then
35 + break
36 + end
38 + i = i + 1
39 + if i > self.skip then
40 + lines = lines .. next
41 + end
42 + until i >= self.skip + limit
44 + child:start_kill()
45 + if self.skip > 0 and i < self.skip + limit then
46 + ya.manager_emit(
47 + "peek",
48 + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" }
49 + )
50 + else
51 + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
52 + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
53 + end
54 +end
56 +function M:seek(units)
57 + local h = cx.active.current.hovered
58 + if h and h.url == self.file.url then
59 + local step = math.floor(units * self.area.h / 10)
60 + ya.manager_emit("peek", {
61 + tostring(math.max(0, cx.active.preview.skip + step)),
62 + only_if = tostring(self.file.url),
63 + })
64 + end
65 +end
67 +return M

yazi/plugins/jump-to-char.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/jump-to-char.yazi/LICENSE

Added
new file mode 100644
1 +MIT License
3 +Copyright (c) 2023 yazi-rs
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.

yazi/plugins/jump-to-char.yazi/README.md

Added
new file mode 100644
1 +# jump-to-char.yazi
3 +Vim-like `f<char>`, jump to the next file whose name starts with `<char>`.
5 +https://github.com/yazi-rs/plugins/assets/17523360/aac9341c-b416-4e0c-aaba-889d48389869
7 +## Installation
9 +```sh
10 +ya pack -a yazi-rs/plugins:jump-to-char
11 +```
13 +## Usage
15 +Add this to your `~/.config/yazi/keymap.toml`:
17 +```toml
18 +[[manager.prepend_keymap]]
19 +on = "f"
20 +run = "plugin jump-to-char"
21 +desc = "Jump to char"
22 +```
24 +Make sure the <kbd>f</kbd> key is not used elsewhere.

yazi/plugins/jump-to-char.yazi/init.lua

Added
new file mode 100644
1 +local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
3 +local changed = ya.sync(function(st, new)
4 + local b = st.last ~= new
5 + st.last = new
6 + return b or not cx.active.finder
7 +end)
9 +local escape = function(s) return s == "." and "\\." or s end
11 +return {
12 + entry = function()
13 + local cands = {}
14 + for i = 1, #AVAILABLE_CHARS do
15 + cands[#cands + 1] = { on = AVAILABLE_CHARS:sub(i, i) }
16 + end
18 + local idx = ya.which { cands = cands, silent = true }
19 + if not idx then
20 + return
21 + end
23 + local kw = escape(cands[idx].on)
24 + if changed(kw) then
25 + ya.manager_emit("find_do", { "^" .. kw })
26 + else
27 + ya.manager_emit("find_arrow", {})
28 + end
29 + end,

yazi/plugins/miller.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/miller.yazi/LICENSE

Added
new file mode 100644
1 +Copyright © 2024 Reledia <reledia@prontonmail.com>
3 +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:
5 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 +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.

yazi/plugins/miller.yazi/README.md

Added
new file mode 100644
1 +# miller.yazi
3 +[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`:
5 +```toml
6 +[plugin]
7 +prepend_previewers = [
8 + { mime = "text/csv", run = "miller"},
9 +]
10 +```
12 +## Preview
14 +![preview](https://github.com/Reledia/miller.yazi/blob/main/preview.png?raw=true)
16 +## Color
18 +To 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.
20 +## Other types of file
22 +To adapt this plugin to the other format supported from miller (like json):
24 +- copy the plugin folder
25 +- change the name of the copied folder into miller\_(fmt)
26 +- change the `--icsv` flag inside `init.lua` to `--i(fmt)`
27 +- add the correct mime/name rule into `prepend_previewers` and the exec as `miller_(fmt)`

yazi/plugins/miller.yazi/init.lua

Added
new file mode 100644
1 +local M = {}
3 +function M:peek()
4 + local child = Command("mlr")
5 + :args({
6 + "--icsv",
7 + "--opprint",
8 + "-C",
9 + "--key-color",
10 + "darkcyan",
11 + "--value-color",
12 + "grey70",
13 + "cat",
14 + tostring(self.file.url),
15 + })
16 + :stdout(Command.PIPED)
17 + :stderr(Command.PIPED)
18 + :spawn()
20 + local limit = self.area.h
21 + local i, lines = 0, ""
22 + repeat
23 + local next, event = child:read_line()
24 + if event == 1 then
25 + ya.err(tostring(event))
26 + elseif event ~= 0 then
27 + break
28 + end
30 + i = i + 1
31 + if i > self.skip then
32 + lines = lines .. next
33 + end
34 + until i >= self.skip + limit
36 + child:start_kill()
37 + if self.skip > 0 and i < self.skip + limit then
38 + ya.manager_emit(
39 + "peek",
40 + { tostring(math.max(0, i - limit)), only_if = tostring(self.file.url), upper_bound = "" }
41 + )
42 + else
43 + lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
44 + ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
45 + end
46 +end
48 +function M:seek(units)
49 + local h = cx.active.current.hovered
50 + if h and h.url == self.file.url then
51 + local step = math.floor(units * self.area.h / 10)
52 + ya.manager_emit("peek", {
53 + tostring(math.max(0, cx.active.preview.skip + step)),
54 + only_if = tostring(self.file.url),
55 + })
56 + end
57 +end
59 +return M

yazi/plugins/ouch.yazi

Added
new file mode 160000
1 +Subproject commit 251da6930ca8b7ee0384810086c3bf644caede3e

yazi/plugins/relative-motions.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/relative-motions.yazi/LICENSE

Added
new file mode 100644
1 +Copyright (c) 2024 dedukun
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.

yazi/plugins/relative-motions.yazi/README.md

Added
new file mode 100644
1 +# relative-motions.yazi
3 +A [Yazi](https://github.com/sxyazi/yazi) plugin based about vim motions.
5 +https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-442d-8d7b-2dccb6eee408
7 +## Requirements
9 +- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
11 +## Installation
13 +```sh
14 +ya pack -a dedukun/relative-motions
15 +```
17 +## Configuration
19 +If you want to use the numbers directly to start a motion add this to your `keymap.toml`:
21 +<details>
23 +```toml
24 +[[manager.prepend_keymap]]
25 +on = [ "1" ]
26 +run = "plugin relative-motions --args=1"
27 +desc = "Move in relative steps"
29 +[[manager.prepend_keymap]]
30 +on = [ "2" ]
31 +run = "plugin relative-motions --args=2"
32 +desc = "Move in relative steps"
34 +[[manager.prepend_keymap]]
35 +on = [ "3" ]
36 +run = "plugin relative-motions --args=3"
37 +desc = "Move in relative steps"
39 +[[manager.prepend_keymap]]
40 +on = [ "4" ]
41 +run = "plugin relative-motions --args=4"
42 +desc = "Move in relative steps"
44 +[[manager.prepend_keymap]]
45 +on = [ "5" ]
46 +run = "plugin relative-motions --args=5"
47 +desc = "Move in relative steps"
49 +[[manager.prepend_keymap]]
50 +on = [ "6" ]
51 +run = "plugin relative-motions --args=6"
52 +desc = "Move in relative steps"
54 +[[manager.prepend_keymap]]
55 +on = [ "7" ]
56 +run = "plugin relative-motions --args=7"
57 +desc = "Move in relative steps"
59 +[[manager.prepend_keymap]]
60 +on = [ "8" ]
61 +run = "plugin relative-motions --args=8"
62 +desc = "Move in relative steps"
64 +[[manager.prepend_keymap]]
65 +on = [ "9" ]
66 +run = "plugin relative-motions --args=9"
67 +desc = "Move in relative steps"
68 +```
70 +</details>
72 +Alternatively you can use a key to trigger a new motion without any initial value, for that add the following in `keymap.toml`:
74 +```toml
75 +[[manager.prepend_keymap]]
76 +on = [ "m" ]
77 +run = "plugin relative-motions"
78 +desc = "Trigger a new relative motion"
79 +```
81 +---
83 +Additionally there are a couple of initial configurations that can be given to the plugin's `setup` function:
85 +| Configuration | Values | Default | Description |
86 +| -------------- | ----------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- |
87 +| `show_numbers` | `relative`, `absolute`, `relative_absolute` or `none` | `none` | Shows relative or absolute numbers before the file icon |
88 +| `show_motion` | `true` or `false` | `false` | Shows current motion in Status bar |
89 +| `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 |
91 +If you want, for example, to enable relative numbers as well as to show the motion in the status bar,
92 +add the following to Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`:
94 +```lua
95 +-- ~/.config/yazi/init.lua
96 +require("relative-motions"):setup({ show_numbers="relative", show_motion = true })
97 +```
99 +> [!NOTE]
100 +> The `show_numbers` and `show_motion` functionalities overwrite [`Current:render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/current.lua#L26)
101 +> and [`Status:children_render`](https://github.com/sxyazi/yazi/blob/ec33085f672e52adb934503d78703b8dd70621a8/yazi-plugin/preset/components/status.lua#L173) respectively.
102 +> If you have custom implementations for any of this functions
103 +> 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.
105 +## Usage
107 +This plugin adds the some basic vim motions like `3k`, `12j`, `10gg`, etc.
108 +The following table show all the available motions:
110 +| Command | Description |
111 +| -------------- | ------------------- |
112 +| `j`/`<Down>` | Move `n` lines down |
113 +| `k`/`<Up>` | Move `n` lines up |
114 +| `gj`/`g<Down>` | Go `n` lines down |
115 +| `gk`/`g<Up>` | Go `n` lines up |
116 +| `gg` | Go to line |
118 +Furthermore, the following operations were also added:
120 +| Command | Description |
121 +| ------- | ------------- |
122 +| `v` | visual select |
123 +| `y` | Yank |
124 +| `x` | Cut |
125 +| `d` | Delete motion |
127 +This however must be followed by a direction, which can be `j`/`<Down>`, `k`/`<Up>` or repeating the command key,
128 +which will operate from the cursor down, e.g. `2yy` will copy two files.
130 +Finally, we also support some tab operations:
132 +| Command | Description |
133 +| ------- | ------------------------------------ |
134 +| `t` | create `n` tabs |
135 +| `H` | Move `n` tabs left |
136 +| `L` | Move `n` tabs right |
137 +| `gt` | Go to the `n` tab |
138 +| `w` | Close tab `n` |
139 +| `W` | Close `n` tabs right |
140 +| `<` | Swap current tab with `n` tabs left |
141 +| `>` | Swap current tab with `n` tabs right |
142 +| `~` | Swap current tab with tab `n` |

yazi/plugins/relative-motions.yazi/init.lua

Added
new file mode 100644
1 +-- stylua: ignore
2 +local MOTIONS_AND_OP_KEYS = {
3 + { on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
4 + { on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" },
5 + -- commands
6 + { on = "d" }, { on = "v" }, { on = "y" }, { on = "x" },
7 + -- tab commands
8 + { on = "t" }, { on = "L" }, { on = "H" }, { on = "w" },
9 + { on = "W" }, { on = "<" }, { on = ">" }, { on = "~" },
10 + -- movement
11 + { on = "g" }, { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" }
14 +-- stylua: ignore
15 +local MOTION_KEYS = {
16 + { on = "0" }, { on = "1" }, { on = "2" }, { on = "3" }, { on = "4" },
17 + { on = "5" }, { on = "6" }, { on = "7" }, { on = "8" }, { on = "9" },
18 + -- movement
19 + { on = "g" }, { on = "j" }, { on = "k" }
22 +-- stylua: ignore
23 +local DIRECTION_KEYS = {
24 + { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" },
25 + -- tab movement
26 + { on = "t" }
29 +local SHOW_NUMBERS_ABSOLUTE = 0
30 +local SHOW_NUMBERS_RELATIVE = 1
31 +local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2
33 +-----------------------------------------------
34 +----------------- R E N D E R -----------------
35 +-----------------------------------------------
37 +local render_motion_setup = ya.sync(function(_)
38 + ya.render()
40 + Status.motion = function() return ui.Span("") end
42 + Status.children_render = function(self, side)
43 + local lines = {}
44 + if side == self.RIGHT then
45 + lines[1] = self:motion(self)
46 + end
47 + for _, c in ipairs(side == self.RIGHT and self._right or self._left) do
48 + lines[#lines + 1] = (type(c[1]) == "string" and self[c[1]] or c[1])(self)
49 + end
50 + return ui.Line(lines)
51 + end
53 + -- TODO: check why it doesn't work line this
54 + -- Status:children_add(Status.motion, 100, Status.RIGHT)
55 +end)
57 +local render_motion = ya.sync(function(_, motion_num, motion_cmd)
58 + ya.render()
60 + Status.motion = function(self)
61 + if not motion_num then
62 + return ui.Span("")
63 + end
65 + local style = self:style()
67 + local motion_span
68 + if not motion_cmd then
69 + motion_span = ui.Span(string.format(" %3d ", motion_num)):style(style)
70 + else
71 + motion_span = ui.Span(string.format(" %3d%s ", motion_num, motion_cmd)):style(style)
72 + end
74 + return ui.Line {
75 + ui.Span(THEME.status.separator_open):fg(style.bg),
76 + motion_span,
77 + ui.Span(THEME.status.separator_close):fg(style.bg),
78 + ui.Span(" "),
79 + }
80 + end
81 +end)
83 +local render_numbers = ya.sync(function(_, mode)
84 + ya.render()
86 + Entity.number = function(_, index, file, hovered)
87 + local idx
88 + if mode == SHOW_NUMBERS_RELATIVE then
89 + idx = math.abs(hovered - index)
90 + elseif mode == SHOW_NUMBERS_ABSOLUTE then
91 + idx = file.idx
92 + else -- SHOW_NUMBERS_RELATIVE_ABSOLUTE
93 + if hovered == index then
94 + idx = file.idx
95 + else
96 + idx = math.abs(hovered - index)
97 + end
98 + end
100 + -- emulate vim's hovered offset
101 + if idx >= 100 then
102 + return ui.Span(string.format("%4d ", idx))
103 + elseif hovered == index then
104 + return ui.Span(string.format("%3d ", idx))
105 + else
106 + return ui.Span(string.format(" %3d ", idx))
107 + end
108 + end
110 + Current.render = function(self)
111 + local files = self._folder.window
112 + if #files == 0 then
113 + return self:empty()
114 + end
116 + local hovered_index
117 + for i, f in ipairs(files) do
118 + if f:is_hovered() then
119 + hovered_index = i
120 + break
121 + end
122 + end
124 + local entities, linemodes = {}, {}
125 + for i, f in ipairs(files) do
126 + linemodes[#linemodes + 1] = Linemode:new(f):render()
128 + local entity = Entity:new(f)
129 + entities[#entities + 1] = ui.ListItem(ui.Line { Entity:number(i, f, hovered_index), entity:render() })
130 + :style(entity:style())
131 + end
133 + return {
134 + ui.List(self._area, entities),
135 + ui.Paragraph(self._area, linemodes):align(ui.Paragraph.RIGHT),
137 + end
138 +end)
140 +local function render_clear() render_motion() end
142 +-----------------------------------------------
143 +--------- C O M M A N D P A R S E R ---------
144 +-----------------------------------------------
146 +local get_keys = ya.sync(function(state) return state._only_motions and MOTION_KEYS or MOTIONS_AND_OP_KEYS end)
148 +local function normal_direction(dir)
149 + if dir == "<Down>" then
150 + return "j"
151 + elseif dir == "<Up>" then
152 + return "k"
153 + end
154 + return dir
155 +end
157 +local function get_cmd(first_char, keys)
158 + local last_key
159 + local lines = first_char or ""
161 + while true do
162 + render_motion(tonumber(lines))
163 + local key = ya.which { cands = keys, silent = true }
164 + if not key then
165 + return nil, nil, nil
166 + end
168 + last_key = keys[key].on
169 + if not tonumber(last_key) then
170 + last_key = normal_direction(last_key)
171 + break
172 + end
174 + lines = lines .. last_key
175 + end
177 + render_motion(tonumber(lines), last_key)
179 + -- command direction
180 + local direction
181 + if last_key == "g" or last_key == "v" or last_key == "d" or last_key == "y" or last_key == "x" then
182 + DIRECTION_KEYS[#DIRECTION_KEYS + 1] = {
183 + on = last_key,
185 + local direction_key = ya.which { cands = DIRECTION_KEYS, silent = true }
186 + if not direction_key then
187 + return nil, nil, nil
188 + end
190 + direction = DIRECTION_KEYS[direction_key].on
191 + direction = normal_direction(direction)
192 + end
194 + return tonumber(lines), last_key, direction
195 +end
197 +local function is_tab_command(command)
198 + local tab_commands = { "t", "L", "H", "w", "W", "<", ">", "~" }
199 + for _, cmd in ipairs(tab_commands) do
200 + if command == cmd then
201 + return true
202 + end
203 + end
204 + return false
205 +end
207 +local get_active_tab = ya.sync(function(_) return cx.tabs.idx end)
209 +-----------------------------------------------
210 +---------- E N T R Y / S E T U P ----------
211 +-----------------------------------------------
213 +return {
214 + entry = function(_, args)
215 + local initial_value
217 + -- this is checking if the argument is a valid number
218 + if args then
219 + initial_value = tostring(tonumber(args[1]))
220 + if initial_value == "nil" then
221 + return
222 + end
223 + end
225 + local lines, cmd, direction = get_cmd(initial_value, get_keys())
226 + if not lines or not cmd then
227 + -- command was cancelled
228 + render_clear()
229 + return
230 + end
232 + if cmd == "g" then
233 + if direction == "g" then
234 + ya.manager_emit("arrow", { -99999999 })
235 + ya.manager_emit("arrow", { lines - 1 })
236 + render_clear()
237 + return
238 + elseif direction == "j" then
239 + cmd = "j"
240 + elseif direction == "k" then
241 + cmd = "k"
242 + elseif direction == "t" then
243 + ya.manager_emit("tab_switch", { lines - 1 })
244 + render_clear()
245 + return
246 + else
247 + -- no valid direction
248 + render_clear()
249 + return
250 + end
251 + end
253 + if cmd == "j" then
254 + ya.manager_emit("arrow", { lines })
255 + elseif cmd == "k" then
256 + ya.manager_emit("arrow", { -lines })
257 + elseif is_tab_command(cmd) then
258 + if cmd == "t" then
259 + for _ = 1, lines do
260 + ya.manager_emit("tab_create", {})
261 + end
262 + elseif cmd == "H" then
263 + ya.manager_emit("tab_switch", { -lines, relative = true })
264 + elseif cmd == "L" then
265 + ya.manager_emit("tab_switch", { lines, relative = true })
266 + elseif cmd == "w" then
267 + ya.manager_emit("tab_close", { lines - 1 })
268 + elseif cmd == "W" then
269 + local curr_tab = get_active_tab()
270 + local del_tab = curr_tab + lines - 1
271 + for _ = curr_tab, del_tab do
272 + ya.manager_emit("tab_close", { curr_tab - 1 })
273 + end
274 + ya.manager_emit("tab_switch", { curr_tab - 1 })
275 + elseif cmd == "<" then
276 + ya.manager_emit("tab_swap", { -lines })
277 + elseif cmd == ">" then
278 + ya.manager_emit("tab_swap", { lines })
279 + elseif cmd == "~" then
280 + local jump = lines - get_active_tab()
281 + ya.manager_emit("tab_swap", { jump })
282 + end
283 + else
284 + ya.manager_emit("visual_mode", {})
285 + -- invert direction when user specifies it
286 + if direction == "k" then
287 + ya.manager_emit("arrow", { -lines })
288 + elseif direction == "j" then
289 + ya.manager_emit("arrow", { lines })
290 + else
291 + ya.manager_emit("arrow", { lines - 1 })
292 + end
293 + ya.manager_emit("escape", {})
295 + if cmd == "d" then
296 + ya.manager_emit("remove", {})
297 + elseif cmd == "y" then
298 + ya.manager_emit("yank", {})
299 + elseif cmd == "x" then
300 + ya.manager_emit("yank", { cut = true })
301 + end
302 + end
304 + render_clear()
305 + end,
306 + setup = function(state, args)
307 + if not args then
308 + return
309 + end
311 + -- initialize state variables
312 + state._only_motions = args["only_motions"] or false
314 + if args["show_motion"] then
315 + render_motion_setup()
316 + end
318 + if args["show_numbers"] == "absolute" then
319 + render_numbers(SHOW_NUMBERS_ABSOLUTE)
320 + elseif args["show_numbers"] == "relative" then
321 + render_numbers(SHOW_NUMBERS_RELATIVE)
322 + elseif args["show_numbers"] == "relative_absolute" then
323 + render_numbers(SHOW_NUMBERS_RELATIVE_ABSOLUTE)
324 + end
325 + end,

yazi/plugins/video-ffmpeg.yazi/DO_NOT_MODIFY_ANYTHING_IN_THIS_DIRECTORY

Added
new file mode 100644

No text changes.

yazi/plugins/video-ffmpeg.yazi/LICENSE

Added
new file mode 100644
1 +The MIT License (MIT)
3 +Copyright © 2024
6 +Permission is hereby granted, free of charge, to any person obtaining a copy
7 +of this software and associated documentation files (the “Software”), to deal
8 +in the Software without restriction, including without limitation the rights
9 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 +copies of the Software, and to permit persons to whom the Software is
11 +furnished to do so, subject to the following conditions:
13 +The above copyright notice and this permission notice shall be included in
14 +all copies or substantial portions of the Software.
16 +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 +THE SOFTWARE.

yazi/plugins/video-ffmpeg.yazi/README.md

Added
new file mode 100644
1 +# video-ffmpeg.yazi
3 +A plugin for [yazi](https://github.com/sxyazi/yazi) to preview videos without using
4 +[ffmpegthumbnailer](https://github.com/dirkvdb/ffmpegthumbnailer) since I couldn't get it working for windows.
6 +## Requirements
8 +- `ffmpeg`
10 +## Installation
12 +```sh
13 +ya pack -a 'Tyarel8/video-ffmpeg'
14 +```
16 +## Usage
18 +Add this to your `yazi.toml`:
20 +```toml
21 +[plugin]
22 +prepend_previewers = [
23 + { mime = "video/*", run = "video-ffmpeg" },
26 +prepend_preloaders = [
27 + { mime = "video/*", run = "video-ffmpeg" },
29 +```

yazi/plugins/video-ffmpeg.yazi/init.lua

Added
new file mode 100644
1 +local M = {}
3 +function M:peek()
4 + local start, cache = os.clock(), ya.file_cache(self)
5 + if not cache or self:preload() ~= 1 then
6 + return
7 + end
9 + ya.sleep(math.max(0, PREVIEW.image_delay / 1000 + start - os.clock()))
10 + ya.image_show(cache, self.area)
11 + ya.preview_widgets(self, {})
12 +end
14 +function M:seek(units)
15 + local h = cx.active.current.hovered
16 + if h and h.url == self.file.url then
17 + ya.manager_emit("peek", {
18 + math.max(0, cx.active.preview.skip + units),
19 + only_if = self.file.url,
20 + })
21 + end
22 +end
24 +function M:preload()
25 + local percentage = 5 + self.skip
26 + if percentage > 95 then
27 + ya.manager_emit("peek", { 90, only_if = self.file.url, upper_bound = true })
28 + return 2
29 + end
31 + local cache = ya.file_cache(self)
32 + if not cache or fs.cha(cache) then
33 + return 1
34 + end
36 + -- Get the video duration in seconds
37 + local probe = Command("ffprobe"):args({
38 + "-i", tostring(self.file.url), "-show_entries", "format=duration", "-v", "quiet", "-of", "csv=p=0"
39 + }):stdout(Command.PIPED):output()
41 + -- Calculate second to take thumbnail
42 + local sec = tonumber(probe.stdout) * percentage / 100
44 + local child, code = Command("ffmpeg"):args({
45 + "-ss",
46 + -- Replace `,` with `.` to prevent locale issues where the decimal separator is `,`
47 + tostring(sec):gsub(",", "."),
48 + "-i",
49 + tostring(self.file.url),
50 + "-vf",
51 + "scale=" .. tostring(PREVIEW.max_width) .. ":-1",
52 + "-q:v",
53 + "6",
54 + "-frames:v",
55 + "1",
56 + "-f",
57 + "image2",
58 + tostring(cache),
59 + }):spawn()
61 + if not child then
62 + ya.err("spawn `ffmpeg` command returns " .. tostring(code))
63 + return 0
64 + end
66 + local status = child:wait()
67 + return status and status.success and 1 or 2
68 +end
70 +return M

yazi/yazi.toml

Added
new file mode 100644
1 +[plugin]
2 +prepend_previewers = [
3 + { mime = "video/*", run = "video-ffmpeg" },
4 + { mime = "audio/*", run = "exifaudio" },
5 + { mime = "text/csv", run = "miller" },
6 + { mime = "application/*zip", run = "ouch" },
7 + { mime = "application/x-tar", run = "ouch" },
8 + { mime = "application/x-bzip2", run = "ouch" },
9 + { mime = "application/x-7z-compressed", run = "ouch" },
10 + { mime = "application/x-rar", run = "ouch" },
11 + { mime = "application/x-xz", run = "ouch" },
14 +append_previewers = [
15 + { name = "*", run = "hexyl" },
18 +prepend_preloaders = [
19 + { mime = "video/*", run = "video-ffmpeg" }
22 +[opener]
23 +extract = [
24 + { run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
25 + { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
28 +[[plugin.prepend_fetchers]]
29 +id = "git"
30 +name = "*"
31 +run = "git"