repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

Merge branch 'trunk' of github.com:bugabinga/dotfiles into trunk

e181aff30bc5ddcad345100f7bee86d59f092aa3

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (44)

+1851 / −198 text lines · all files grouped into 32 bars

Diff layout

nushell/env.nu

Modified

+2 / −0 text lines

8686 '' | save -f $zoxide_config_path
89# TODO: figure out sensible bridges
90$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense'
8991let carapace_config_path = $nu.default-config-dir | path join 'carapace.nu'
9092if not (which carapace | is-empty) {
9193 carapace _carapace nushell | save --force $carapace_config_path

topgrade/topgrade.linux.toml

Deleted
deleted file mode 100644

+0 / −19 text lines

1[misc]
2disable = ["vim"]
3assume_yes = true
4no_retry = true
5set_title = true
6display_time = true
7cleanup = true
8
9[composer]
10self_update = false
12[git]
13repos = [
14 "/home/oli/Source/*",
15 "/home/oli/Notes"
16]
17arguments = "--ff --rebase"
18max_concurrency = 12
19pull_predefined = false

topgrade/topgrade.termux.toml

Deleted
deleted file mode 100644

+0 / −133 text lines

1# Don't ask for confirmations
2#assume_yes = true
3
4# Disable specific steps - same options as the command line flag
5#disable = ["system", "emacs"]
6
7# Ignore failures for these steps
8#ignore_failures = ["powershell"]
9
10# Run specific steps - same options as the command line flag
11#only = ["system", "emacs"]
13# Do not ask to retry failed steps (default: false)
14#no_retry = true
16# Sudo command to be used
17#sudo_command = "sudo"
19# Run `sudo -v` to cache credentials at the start of the run; this avoids a
20# blocking password prompt in the middle of a possibly-unattended run.
21#pre_sudo = false
23# Run inside tmux
24#run_in_tmux = true
26# List of remote machines with Topgrade installed on them
27#remote_topgrades = ["toothless", "pi", "parnas"]
29# Arguments to pass SSH when upgrading remote systems
30#ssh_arguments = "-o ConnectTimeout=2"
32# Path to Topgrade executable on remote machines
33#remote_topgrade_path = ".cargo/bin/topgrade"
35# Arguments to pass tmux when pulling Repositories
36#tmux_arguments = "-S /var/tmux.sock"
38# Do not set the terminal title
39#set_title = false
41# Display the time in step titles
42# display_time = true
44# Cleanup temporary or old files
45#cleanup = true
47# Skip sending a notification at the end of a run
48#skip_notify = true
50# Skip the preamble displayed when topgrade is run
51#display_preamble = false
53[git]
54#max_concurrency = 5
55# Additional git repositories to pull
56#repos = [
57# "~/src/*/",
58# "~/.config/something"
59#]
61# Don't pull the predefined git repos
62#pull_predefined = false
64# Arguments to pass Git when pulling Repositories
65#arguments = "--rebase --autostash"
67[composer]
68#self_update = true
70# Commands to run before anything
71[pre_commands]
72#"Emacs Snapshot" = "rm -rf ~/.emacs.d/elpa.bak && cp -rl ~/.emacs.d/elpa ~/.emacs.d/elpa.bak"
74# Custom commands
75[commands]
76#"Python Environment" = "~/dev/.env/bin/pip install -i https://pypi.python.org/simple -U --upgrade-strategy eager jupyter"
78[brew]
79#greedy_cask = true
80#autoremove = true
82[linux]
83# Arch Package Manager to use. Allowed values: autodetect, aura, garuda_update, pacman, pamac, paru, pikaur, trizen, yay.
84#arch_package_manager = "pacman"
85# Arguments to pass yay (or paru) when updating packages
86#yay_arguments = "--nodevel"
87# Arguments to pass dnf when updating packages
88#dnf_arguments = "--refresh"
89#aura_aur_arguments = "-kx"
90#aura_pacman_arguments = ""
91#garuda_update_arguments = ""
92#show_arch_news = true
93#trizen_arguments = "--devel"
94#pikaur_arguments = ""
95#pamac_arguments = "--no-devel"
96#enable_tlmgr = true
97#emerge_sync_flags = "-q"
98#emerge_update_flags = "-uDNa --with-bdeps=y world"
99#redhat_distro_sync = false
100#rpm_ostree = false
101#nix_arguments = "--flake"
103[python]
104#enable_pip_review = true ###disabled by default
105#enable_pipupgrade = true ###disabled by default
107[windows]
108# Manually select Windows updates
109#accept_all_updates = false
110#open_remotes_in_new_terminal = true
111#wsl_update_pre_release = true
112#wsl_update_use_web_download = true
114# Causes Topgrade to rename itself during the run to allow package managers
115# to upgrade it. Use this only if you installed Topgrade by using a package
116# manager such as Scoop or Cargo
117#self_rename = true
119[npm]
120# Use sudo if the NPM directory isn't owned by the current user
121#use_sudo = true
123[firmware]
124# Offer to update firmware; if false just check for and display available updates
125#upgrade = true
127[flatpak]
128# Use sudo for updating the system-wide installation
129#use_sudo = true
131[distrobox]
132#use_root = false
133#containers = ["archlinux-latest"]

topgrade/topgrade.windows.toml

Deleted
deleted file mode 100644

+0 / −46 text lines

1[misc]
2# Disable specific steps - same options as the command line flag
3# disable = ["system"]
4disable = ["vim"]
5
6assume_yes = true
7
8# Run specific steps - same options as the command line flag
9#only = ["system", "emacs"]
11# Do not ask to retry failed steps (default: false)
12no_retry = true
14# Do not set the terminal title
15set_title = true
17# Display the time in step titles
18display_time = true
20# Cleanup temporary or old files
21cleanup = true
23[composer]
24self_update = true
26[git]
27# Additional git repositories to pull
28repos = ["C:/Users/okr/Workspaces/*/"]
30max_concurrency = 12
32pull_predefined = false
34# Arguments to pass Git when pulling Repositories
35# arguments = "--ff --rebase"
37# Commands to run before anything
38[pre_commands]
39"01 - Winget Export" = "winget export --disable-interactivity --accept-source-agreements --output 'C:/Users/okr/Tools/winget_installed_apps.json' *> $null"
41[commands]
42"10 - Refresh dotfiles" = "java W:/dotfiles/bootstripper.java W:/dotfiles"
43"20 - Install Cargo Tools" = "cd W:/dotfiles/tools ; java install.java"
44"30 - Advantage-PM Client" = "nu X:/update_apm_client.nu"
45"31 - MeMate" = "nu X:/update_memate.nu"
46"40 - TLDR" = "tldr --update"

wezterm/bugabinga/titles.lua

Added
new file mode 100644

+27 / −0 text lines

1local wez = require 'wezterm'
2
3-- Equivalent to POSIX basename(3)
4-- Given "/foo/bar" returns "bar"
5-- Given "c:\\foo\\bar" returns "bar"
6local function basename( s )
7 return string.gsub( s, '(.*[/\\])(.*)', '%2' )
8end
9
10local 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 .. ' '
20end
22return function ( _ )
23 wez.on(
24 'format-tab-title',
25 function ( tab ) return tab_title( tab ) end
26 )
27end

yazi/init.lua

Added
new file mode 100644

+3 / −0 text lines

1require("relative-motions"):setup({ show_numbers="relative", show_motion = true })
2
3require("git"):setup()

yazi/keymap.toml

Added
new file mode 100644

+19 / −0 text lines

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

yazi/package.toml

Added
new file mode 100644

+14 / −0 text lines

1[plugin]
2deps = [
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" }
11]
13[flavor]
14deps = []

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

+21 / −0 text lines

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

yazi/plugins/diff.yazi/README.md

Added
new file mode 100644

+24 / −0 text lines

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

yazi/plugins/diff.yazi/init.lua

Added
new file mode 100644

+37 / −0 text lines

1local function info(content)
2 return ya.notify {
3 title = "Diff",
4 content = content,
5 timeout = 5,
6 }
7end
8
9local selected_url = ya.sync(function()
10 for _, u in pairs(cx.active.selected) do
11 return u
12 end
13end)
15local hovered_url = ya.sync(function()
16 local h = cx.active.current.hovered
17 return h and h.url
18end)
20return {
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,
37}

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

+21 / −0 text lines

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

yazi/plugins/exifaudio.yazi/README.md

Added
new file mode 100644

+38 / −0 text lines

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

+215 / −0 text lines

1local M = {}
2
3function GetPath(str)
4 local sep = '/'
5 if ya.target_family() == "windows" then
6 sep = '\\'
7 end
8 return str:match("(.*"..sep..")")
9end
11function 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
28end
30function 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
41end
43function 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
102end
104function 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:"
134 }
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
157end
159function 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
167end
169function 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%)\
193"\
194Audio;"Sample Rate: %SamplingRate%\
195Channels: %Channel(s)%"\
196'
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
213end
215return 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

+21 / −0 text lines

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

yazi/plugins/git.yazi/README.md

Added
new file mode 100644

+77 / −0 text lines

1# git.yazi
2
3> [!NOTE]
4> Yazi v0.3.3 or later is required for this plugin to work.
5
6Show the status of Git file changes as linemode in the file list.
7
8https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576
9
10## Installation
12```sh
13ya pack -a yazi-rs/plugins:git
14```
16## Setup
18Add the following to your `~/.config/yazi/init.lua`:
20```lua
21require("git"):setup()
22```
24And register it as fetchers in your `~/.config/yazi/yazi.toml`:
26```toml
27[[plugin.prepend_fetchers]]
28id = "git"
29name = "*"
30run = "git"
32[[plugin.prepend_fetchers]]
33id = "git"
34name = "*/"
35run = "git"
36```
38## Advanced
40> [!NOTE]
41> This section currently requires Yazi nightly that includes https://github.com/sxyazi/yazi/pull/1637
43You 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`
52For example:
54```lua
55-- ~/.config/yazi/init.lua
56THEME.git = THEME.git or {}
57THEME.git.modified = ui.Style():fg("blue")
58THEME.git.deleted = ui.Style():fg("red"):bold()
59```
61You 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`
70For example:
72```lua
73-- ~/.config/yazi/init.lua
74THEME.git = THEME.git or {}
75THEME.git.modified_sign = "M"
76THEME.git.deleted_sign = "D"
77```

yazi/plugins/git.yazi/init.lua

Added
new file mode 100644

+198 / −0 text lines

1local WIN = ya.target_family() == "windows"
2local 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
10}
12local 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
27end
29local 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
37end
39local 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
52end
54local 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
66end
68local 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()
81end)
83local 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
101end)
103local 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"),
119 }
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",
127 }
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)
145end
147local 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
196end
198return { 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

+7 / −0 text lines

1Copyright © 2024 Reledia <reledia@prontonmail.com>
2
3Permission 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:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE 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

+22 / −0 text lines

1# hexyl.yazi
2
3Preview any file on [Yazi](https://github.com/sxyazi/yazi) using [hexyl](https://github.com/sharkdp/hexyl). To install, use the `ya pack` cli utility:
4
5```bash
6ya pack -a Reledia/hexyl
7```
8
9then include it in your `yazi.toml` to use:
11```toml
12[plugin]
13append_previewers = [
14 { name = "*", run = "hexyl" },
15]
16```
18Make 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

+67 / −0 text lines

1local M = {}
2
3function 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
54end
56function 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
65end
67return 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

+21 / −0 text lines

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

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

Added
new file mode 100644

+24 / −0 text lines

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

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

Added
new file mode 100644

+30 / −0 text lines

1local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
2
3local changed = ya.sync(function(st, new)
4 local b = st.last ~= new
5 st.last = new
6 return b or not cx.active.finder
7end)
8
9local escape = function(s) return s == "." and "\\." or s end
11return {
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,
30}

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

+7 / −0 text lines

1Copyright © 2024 Reledia <reledia@prontonmail.com>
2
3Permission 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:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE 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

+27 / −0 text lines

1# miller.yazi
2
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`:
4
5```toml
6[plugin]
7prepend_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
18To 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
22To 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

+59 / −0 text lines

1local M = {}
2
3function 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
46end
48function 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
57end
59return M

yazi/plugins/ouch.yazi/LICENSE

Added
new file mode 100644

+21 / −0 text lines

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

yazi/plugins/ouch.yazi/README.md

Added
new file mode 100644

+67 / −0 text lines

1# ouch.yazi
2
3[ouch](https://github.com/ouch-org/ouch) plugin for [Yazi](https://github.com/sxyazi/yazi).
4
5![ouch.yazi](https://github.com/ndtoan96/ouch.yazi/assets/33489972/946397ec-b37b-4bf4-93f1-c676fc8e59f2)
6
7## Features
8- Archive preview
9- Compression
11## Installation
13```bash
14# Linux/macOS
15git clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
17# Windows
18git clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
19```
21Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.
23## Usage
25### Preview
26For archive preview, add this to your `yazi.toml`:
28```toml
29[plugin]
30prepend_previewers = [
31 # Archive previewer
32 { mime = "application/*zip", run = "ouch" },
33 { mime = "application/x-tar", run = "ouch" },
34 { mime = "application/x-bzip2", run = "ouch" },
35 { mime = "application/x-7z-compressed", run = "ouch" },
36 { mime = "application/x-rar", run = "ouch" },
37 { mime = "application/x-xz", run = "ouch" },
38]
39```
41Now 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.
43If 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).
45### Compression
46For compession, add this to your `keymap.toml`:
48```toml
49[[manager.prepend_keymap]]
50on = ["C"]
51run = "plugin ouch --args=zip"
52desc = "Compress with ouch"
53```
55The `--args=zip` part tells the plugin that default format is `zip`. You can change that to whatever format you want.
57### Decompression
58This plugin does not provide a decompression feature because it already is supported by Yazi.
59To decompress with `ouch`, configure the opener in `yazi.toml`.
61```toml
62[opener]
63extract = [
64 { run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
65 { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
66]
67```

yazi/plugins/ouch.yazi/init.lua

Added
new file mode 100644

+143 / −0 text lines

1local M = {}
2
3function M:peek()
4 local child = Command("ouch")
5 :args({ "l", "-t", "-y", tostring(self.file.url) })
6 :stdout(Command.PIPED)
7 :stderr(Command.PIPED)
8 :spawn()
9 local limit = self.area.h
10 local file_name = string.match(tostring(self.file.url), ".*[/\\](.*)")
11 local lines = string.format("\x1b[2m📁 %s\x1b[0m\n", file_name)
12 local num_lines = 1
13 local num_skip = 0
14 repeat
15 local line, event = child:read_line()
16 if event == 1 then
17 ya.err(tostring(event))
18 elseif event ~= 0 then
19 break
20 end
22 if line:find('Archive', 1, true) ~= 1 and line:find('[INFO]', 1, true) ~= 1 then
23 if num_skip >= self.skip then
24 lines = lines .. line
25 num_lines = num_lines + 1
26 else
27 num_skip = num_skip + 1
28 end
29 end
30 until num_lines >= limit
32 child:start_kill()
33 if self.skip > 0 and num_lines < limit then
34 ya.manager_emit(
35 "peek",
36 { tostring(math.max(0, self.skip - (limit - num_lines))), only_if = tostring(self.file.url), upper_bound = "" }
37 )
38 else
39 ya.preview_widgets(self, { ui.Paragraph.parse(self.area, lines) })
40 end
41end
43function M:seek(units)
44 local h = cx.active.current.hovered
45 if h and h.url == self.file.url then
46 local step = math.floor(units * self.area.h / 10)
47 ya.manager_emit("peek", {
48 math.max(0, cx.active.preview.skip + step),
49 only_if = tostring(self.file.url),
50 })
51 end
52end
54-- Check if file exists
55local function file_exists(name)
56 local f = io.open(name, "r")
57 if f ~= nil then
58 io.close(f)
59 return true
60 else
61 return false
62 end
63end
65-- Get the files that need to be compressed and infer a default archive name
66local get_compression_target = ya.sync(function()
67 local tab = cx.active
68 local default_name
69 local paths = {}
70 if #tab.selected == 0 then
71 if tab.current.hovered then
72 local name = tab.current.hovered.name
73 default_name = name
74 table.insert(paths, name)
75 else
76 return
77 end
78 else
79 default_name = tab.current.cwd:name()
80 for _, url in pairs(tab.selected) do
81 table.insert(paths, tostring(url))
82 end
83 -- The compression targets are aquired, now unselect them
84 ya.manager_emit("escape", {})
85 end
86 return paths, default_name
87end)
89local function invoke_compress_command(paths, name)
90 local cmd_output, err_code = Command("ouch")
91 :args({ "c", "-y" })
92 :args(paths)
93 :arg(name)
94 :stderr(Command.PIPED)
95 :output()
96 if err_code ~= nil then
97 ya.notify({
98 title = "Failed to run ouch command",
99 content = "Status: " .. err_code,
100 timeout = 5.0,
101 level = "error",
102 })
103 elseif not cmd_output.status.success then
104 ya.notify({
105 title = "Compression failed: status code " .. cmd_output.status.code,
106 content = cmd_output.stderr,
107 timeout = 5.0,
108 level = "error",
109 })
110 end
111end
113function M:entry(args)
114 local default_fmt = args[1]
116 -- Get the files that need to be compressed and infer a default archive name
117 local paths, default_name = get_compression_target()
119 -- Get archive name from user
120 local output_name, name_event = ya.input({
121 title = "Create archive:",
122 value = default_name .. "." .. default_fmt,
123 position = { "top-center", y = 3, w = 40 },
124 })
125 if name_event ~= 1 then
126 return
127 end
129 -- Get confirmation if file exists
130 if file_exists(output_name) then
131 local confirm, confirm_event = ya.input({
132 title = "Overwrite " .. output_name .. "? (y/N)",
133 position = { "top-center", y = 3, w = 40 },
134 })
135 if not (confirm_event == 1 and confirm:lower() == "y") then
136 return
137 end
138 end
140 invoke_compress_command(paths, output_name)
141end
143return M

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

+19 / −0 text lines

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

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

Added
new file mode 100644

+142 / −0 text lines

1# relative-motions.yazi
2
3A [Yazi](https://github.com/sxyazi/yazi) plugin based about vim motions.
4
5https://github.com/dedukun/relative-motions.yazi/assets/25795432/04fb186a-5efe-442d-8d7b-2dccb6eee408
6
7## Requirements
8
9- [Yazi](https://github.com/sxyazi/yazi) v0.3.0+
11## Installation
13```sh
14ya pack -a dedukun/relative-motions
15```
17## Configuration
19If 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]]
25on = [ "1" ]
26run = "plugin relative-motions --args=1"
27desc = "Move in relative steps"
29[[manager.prepend_keymap]]
30on = [ "2" ]
31run = "plugin relative-motions --args=2"
32desc = "Move in relative steps"
34[[manager.prepend_keymap]]
35on = [ "3" ]
36run = "plugin relative-motions --args=3"
37desc = "Move in relative steps"
39[[manager.prepend_keymap]]
40on = [ "4" ]
41run = "plugin relative-motions --args=4"
42desc = "Move in relative steps"
44[[manager.prepend_keymap]]
45on = [ "5" ]
46run = "plugin relative-motions --args=5"
47desc = "Move in relative steps"
49[[manager.prepend_keymap]]
50on = [ "6" ]
51run = "plugin relative-motions --args=6"
52desc = "Move in relative steps"
54[[manager.prepend_keymap]]
55on = [ "7" ]
56run = "plugin relative-motions --args=7"
57desc = "Move in relative steps"
59[[manager.prepend_keymap]]
60on = [ "8" ]
61run = "plugin relative-motions --args=8"
62desc = "Move in relative steps"
64[[manager.prepend_keymap]]
65on = [ "9" ]
66run = "plugin relative-motions --args=9"
67desc = "Move in relative steps"
68```
70</details>
72Alternatively 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]]
76on = [ "m" ]
77run = "plugin relative-motions"
78desc = "Trigger a new relative motion"
79```
81---
83Additionally 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 |
91If you want, for example, to enable relative numbers as well as to show the motion in the status bar,
92add the following to Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`:
94```lua
95-- ~/.config/yazi/init.lua
96require("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
107This plugin adds the some basic vim motions like `3k`, `12j`, `10gg`, etc.
108The 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 |
118Furthermore, the following operations were also added:
120| Command | Description |
121| ------- | ------------- |
122| `v` | visual select |
123| `y` | Yank |
124| `x` | Cut |
125| `d` | Delete motion |
127This however must be followed by a direction, which can be `j`/`<Down>`, `k`/`<Up>` or repeating the command key,
128which will operate from the cursor down, e.g. `2yy` will copy two files.
130Finally, 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

+326 / −0 text lines

1-- stylua: ignore
2local 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>" }
12}
14-- stylua: ignore
15local 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" }
20}
22-- stylua: ignore
23local DIRECTION_KEYS = {
24 { on = "j" }, { on = "k" }, { on = "<Down>" }, { on = "<Up>" },
25 -- tab movement
26 { on = "t" }
27}
29local SHOW_NUMBERS_ABSOLUTE = 0
30local SHOW_NUMBERS_RELATIVE = 1
31local SHOW_NUMBERS_RELATIVE_ABSOLUTE = 2
33-----------------------------------------------
34----------------- R E N D E R -----------------
35-----------------------------------------------
37local 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)
55end)
57local 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
81end)
83local 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),
136 }
137 end
138end)
140local function render_clear() render_motion() end
142-----------------------------------------------
143--------- C O M M A N D P A R S E R ---------
144-----------------------------------------------
146local get_keys = ya.sync(function(state) return state._only_motions and MOTION_KEYS or MOTIONS_AND_OP_KEYS end)
148local 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
155end
157local 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,
184 }
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
195end
197local 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
205end
207local get_active_tab = ya.sync(function(_) return cx.tabs.idx end)
209-----------------------------------------------
210---------- E N T R Y / S E T U P ----------
211-----------------------------------------------
213return {
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,
326}

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

+22 / −0 text lines

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

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

Added
new file mode 100644

+29 / −0 text lines

1# video-ffmpeg.yazi
2
3A 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.
5
6## Requirements
7
8- `ffmpeg`
9
10## Installation
12```sh
13ya pack -a 'Tyarel8/video-ffmpeg'
14```
16## Usage
18Add this to your `yazi.toml`:
20```toml
21[plugin]
22prepend_previewers = [
23 { mime = "video/*", run = "video-ffmpeg" },
24]
26prepend_preloaders = [
27 { mime = "video/*", run = "video-ffmpeg" },
28]
29```

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

Added
new file mode 100644

+70 / −0 text lines

1local M = {}
2
3function 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
8
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, {})
12end
14function 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
22end
24function 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
68end
70return M

yazi/yazi.toml

Added
new file mode 100644

+31 / −0 text lines

1[plugin]
2prepend_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" },
12]
14append_previewers = [
15 { name = "*", run = "hexyl" },
16]
18prepend_preloaders = [
19 { mime = "video/*", run = "video-ffmpeg" }
20]
22[opener]
23extract = [
24 { run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
25 { run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
26]
28[[plugin.prepend_fetchers]]
29id = "git"
30name = "*"
31run = "git"