updated yazi config

This commit is contained in:
liph committed 2026-08-29 10:41:08 +02:00
1 parent a8a1b5a718
commit 6868bb0f46
38 files changed
+4634 -66

No files matched your search

+83 -36
View File
@@ -1,43 +1,96 @@
--- eza-preview ---
require("eza-preview"):setup({
-- Set the tree preview to be default (default: true)
default_tree = true,
-- Directory depth level for tree preview (default: 3)
level = 3,
-- Show file icons
icons = true,
-- Follow symlinks when previewing directories (default: true)
follow_symlinks = true,
-- Show target file info instead of symlink info (default: false)
dereference = false,
-- Show hidden files (default: true)
all = true,
-- Ignore files matching patterns (default: {})
-- ignore_glob = "*.log"
-- ignore_glob = { "*.tmp", "node_modules", ".git", ".DS_Store" }
-- SEE: https://www.linuxjournal.com/content/pattern-matching-bash to learn about glob patterns
ignore_glob = {},
-- Ignore files mentioned in '.gitignore' (default: true)
git_ignore = true,
-- Show git status (default: false)
git_status = false,
})
-- -- Or use default settings
-- require("eza-preview"):setup({})
--- omp ---
require("omp"):setup({ config = "/home/liph/.config/yazi/omp/omp.toml" })
--- yatlint ---
require("yaziline"):setup({
color = "#98c379",
secondary_color = "#5a6078",
default_files_color = "darkgray", -- color of the file counter when it's inactive
selected_files_color = "white",
yanked_files_color = "green",
cut_files_color = "red",
separator_style = "angly", -- "angly" | "curvy" | "liney" | "empty"
separator_open = "",
separator_close = "",
separator_open_thin = "",
separator_close_thin = "",
separator_head = "",
separator_tail = "",
select_symbol = "",
yank_symbol = "󰆐",
filename_max_length = 24, -- truncate when filename > 24
filename_truncate_length = 6, -- leave 6 chars on both sides
filename_truncate_separator = "...",
})
--- git ---
require("git"):setup({
-- Order of status signs showing in the linemode
order = 1500,
})
--- tab restore ---
require("close-and-restore-tab"):setup()
--- yafg ---
require("yafg"):setup({
toggle_mode_key = "alt-t", -- fzf key to switch ripgrep/fzf mode (default: "ctrl-t")
editor = "nvim", -- Editor command (default: "hx")
args = { "--noplugin" }, -- Additional editor arguments (default: {})
file_arg_format = "+{row} {file}", -- File argument format (default: "{file}:{row}:{col}")
})
--- whoosh --- --- whoosh ---
-- --
local bookmarks = { -- local bookmarks = {
{ tag = "Desktop", path = "~/Desktop", key = "d" }, -- { tag = "Desktop", path = "~/Desktop", key = "d" },
{ tag = "Documents", path = "~/Documents", key = "D" }, -- { tag = "Documents", path = "~/Documents", key = "D" },
{ tag = "Downloads", path = "~/Downloads", key = "o" }, -- { tag = "Downloads", path = "~/Downloads", key = "o" },
} -- }
-- -- You can also configure bookmarks with key arrays
-- You can also configure bookmarks with key arrays -- local bookmarks = {
local bookmarks = { -- { tag = "Desktop", path = "~/Desktop", key = { "d", "D" } },
{ tag = "Desktop", path = "~/Desktop", key = { "d", "D" } }, -- { tag = "Documents", path = "~/Documents", key = { "d", "d" } },
{ tag = "Documents", path = "~/Documents", key = { "d", "d" } }, -- { tag = "Downloads", path = "~/Downloads", key = "o" },
{ tag = "Downloads", path = "~/Downloads", key = "o" }, -- }
}
-- Windows-specific bookmarks
if ya.target_family() == "windows" then
local home_path = os.getenv("USERPROFILE")
table.insert(bookmarks, {
tag = "Scoop Local",
path = os.getenv("SCOOP") or (home_path .. "\\scoop"),
key = "p",
})
table.insert(bookmarks, {
tag = "Scoop Global",
path = os.getenv("SCOOP_GLOBAL") or "C:\\ProgramData\\scoop",
key = "P",
})
end
require("whoosh"):setup({ require("whoosh"):setup({
-- Configuration bookmarks (cannot be deleted through plugin) -- Configuration bookmarks (cannot be deleted through plugin)
bookmarks = bookmarks, bookmarks = bookmarks,
-- Notification settings -- Notification settings
jump_notify = false, jump_notify = false,
-- Key generation for auto-assigning bookmark keys -- Key generation for auto-assigning bookmark keys
keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
-- Configure the built-in menu action hotkeys -- Configure the built-in menu action hotkeys
-- false - hide menu item -- false - hide menu item
special_keys = { special_keys = {
@@ -47,29 +100,23 @@ require("whoosh"):setup({
previous_dir = "<Backspace>", -- Jump back to the previous directory previous_dir = "<Backspace>", -- Jump back to the previous directory
project_root = "-", -- Jump to the current Git repository root project_root = "-", -- Jump to the current Git repository root
}, },
-- File path for storing user bookmarks -- File path for storing user bookmarks
bookmarks_path = ( bookmarks_path = (
ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\plugins\\whoosh.yazi\\bookmarks" ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\plugins\\whoosh.yazi\\bookmarks"
) or (os.getenv("HOME") .. "/.config/yazi/plugins/whoosh.yazi/bookmarks"), ) or (os.getenv("HOME") .. "/.config/yazi/plugins/whoosh.yazi/bookmarks"),
-- Replace home directory with "~" -- Replace home directory with "~"
home_alias_enabled = true, -- Toggle home aliasing in displays home_alias_enabled = true, -- Toggle home aliasing in displays
-- Path truncation in navigation menu -- Path truncation in navigation menu
path_truncate_enabled = false, -- Enable/disable path truncation path_truncate_enabled = false, -- Enable/disable path truncation
path_max_depth = 3, -- Maximum path depth before truncation path_max_depth = 3, -- Maximum path depth before truncation
-- Path truncation in fuzzy search (fzf) -- Path truncation in fuzzy search (fzf)
fzf_path_truncate_enabled = false, -- Enable/disable path truncation in fzf fzf_path_truncate_enabled = false, -- Enable/disable path truncation in fzf
fzf_path_max_depth = 5, -- Maximum path depth before truncation in fzf fzf_path_max_depth = 5, -- Maximum path depth before truncation in fzf
-- Long folder name truncation -- Long folder name truncation
path_truncate_long_names_enabled = false, -- Enable in navigation menu path_truncate_long_names_enabled = false, -- Enable in navigation menu
fzf_path_truncate_long_names_enabled = false, -- Enable in fzf fzf_path_truncate_long_names_enabled = false, -- Enable in fzf
path_max_folder_name_length = 20, -- Max length in navigation menu path_max_folder_name_length = 20, -- Max length in navigation menu
fzf_path_max_folder_name_length = 20, -- Max length in fzf fzf_path_max_folder_name_length = 20, -- Max length in fzf
-- History directory settings -- History directory settings
history_size = 10, -- Number of directories in history (default 10) history_size = 10, -- Number of directories in history (default 10)
history_fzf_path_truncate_enabled = false, -- Enable/disable path truncation by depth for history history_fzf_path_truncate_enabled = false, -- Enable/disable path truncation by depth for history
+93 -29
View File
@@ -4,6 +4,70 @@
#:schema https://yazi-rs.github.io/schemas/keymap.json #:schema https://yazi-rs.github.io/schemas/keymap.json
[mgr] [mgr]
# ~/.config/yazi/keymap.toml
### omni-trash ###
[[mgr.prepend_keymap]]
on = "R"
run = "plugin omni-trash"
desc = "Open Omni Trash"
### lazy git ###
[[mgr.prepend_keymap]]
on = ["g", "i"]
run = "plugin lazygit"
desc = "run lazygit"
### restore-tab ###
[[mgr.prepend_keymap]]
on = "<C-t>"
run = "plugin close-and-restore-tab restore"
desc = "Restore the previously closed tab"
[[mgr.prepend_keymap]]
on = "<C-w>"
run = "close"
desc = "Close the current tab, or quit if it's last"
### projects ###
[[mgr.prepend_keymap]]
on = ["P", "s"]
run = "plugin projects save"
desc = "Save current project"
[[mgr.prepend_keymap]]
on = ["P", "l"]
run = "plugin projects load"
desc = "Load project"
[[mgr.prepend_keymap]]
on = ["P", "P"]
run = "plugin projects load_last"
desc = "Load last project"
[[mgr.prepend_keymap]]
on = ["P", "d"]
run = "plugin projects delete"
desc = "Delete project"
[[mgr.prepend_keymap]]
on = ["P", "D"]
run = "plugin projects delete_all"
desc = "Delete all projects"
[[mgr.prepend_keymap]]
on = ["P", "m"]
run = "plugin projects 'merge current'"
desc = "Merge current tab to other projects"
[[mgr.prepend_keymap]]
on = ["P", "M"]
run = "plugin projects 'merge all'"
desc = "Merge current project to other projects"
### yapfg ###l
[[mgr.prepend_keymap]]
on = ["A", "G"]
run = "plugin yafg"
### lsblk ###
[[mgr.prepend_keymap]]
on = "M"
run = "plugin lsblk-mount"
desc = "Open the drive mount manager"
### chmod ### ### chmod ###
[[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
@@ -72,35 +136,35 @@ on = ["]", "R"]
run = "plugin whoosh rename_by_fzf" run = "plugin whoosh rename_by_fzf"
desc = "Rename bookmark by fzf" desc = "Rename bookmark by fzf"
# ### eza-preview ### ### eza-preview ###
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "t"] on = ["E", "t"]
# run = "plugin eza-preview" run = "plugin eza-preview"
# desc = "Toggle tree/list dir preview" desc = "Toggle tree/list dir preview"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "-"] on = ["E", "-"]
# run = "plugin eza-preview inc-level" run = "plugin eza-preview inc-level"
# desc = "Increment tree level" desc = "Increment tree level"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "_"] on = ["E", "_"]
# run = "plugin eza-preview dec-level" run = "plugin eza-preview dec-level"
# desc = "Decrement tree level" desc = "Decrement tree level"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "$"] on = ["E", "$"]
# run = "plugin eza-preview toggle-follow-symlinks" run = "plugin eza-preview toggle-follow-symlinks"
# desc = "Toggle tree follow symlinks" desc = "Toggle tree follow symlinks"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "*"] on = ["E", "*"]
# run = "plugin eza-preview toggle-hidden" run = "plugin eza-preview toggle-hidden"
# desc = "Toggle hidden files" desc = "Toggle hidden files"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "g", "i"] on = ["E", "g", "i"]
# run = "plugin eza-preview toggle-git-ignore" run = "plugin eza-preview toggle-git-ignore"
# desc = "Toggle .gitignore files" desc = "Toggle .gitignore files"
# [[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
# on = ["R", "g", "s"] on = ["E", "g", "s"]
# run = "plugin eza-preview toggle-git-status" run = "plugin eza-preview toggle-git-status"
# desc = "Toggle showing git status" desc = "Toggle showing git status"
### smart-enter ### ### smart-enter ###
[[mgr.prepend_keymap]] [[mgr.prepend_keymap]]
+103
View File
@@ -0,0 +1,103 @@
"$schema" = "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json"
pwd = "osc7"
version = 3
[palette]
gb_bright_path = "#7daea3"
gb_bright_git = "#d8a657"
gb_dark0_hard = "#3e7fb0"
gb_faded_green = "#79740e"
gb_faded_red = "#ea9a97"
gb_text = "#d3869b"
[var]
user = ""
ssh = "🌐"
# LEFT SIDE PROMPT
[[blocks]]
type = "prompt"
alignment = "left"
[[blocks.segments]]
template = '{{ .HostName }} '
foreground = 'magenta'
background = 'transparent'
type = 'text'
style = 'plain'
[[blocks.segments]]
template = '{{ .UserName }} '
foreground = 'magenta'
background = 'transparent'
type = 'text'
style = 'plain'
# [blocks.segments.properties]
# cache_duration = "none"
[[blocks.segments]]
template = "{{ .Path }} "
foreground = "blue"
background = "transparent"
type = "path"
style = "plain"
[blocks.segments.properties]
style = "full"
enable_hyperlink = true
[[blocks.segments]]
template = ' {{ .HEAD }}{{ if or (.Working.Changed) (.Staging.Changed) }}*{{ end }} <cyan>{{ if gt .Behind 0 }}⇣{{ end }}{{ if gt .Ahead 0 }}⇡{{ end }}</>'
foreground = "yellow"
background = "transparent"
type = "git"
style = "plain"
[blocks.segments.properties]
fetch_status = true
[blocks.segments.properties.status_formats]
Added = "+%d"
Deleted = "-%d"
Modified = "~%d"
Untracked = "?%d"
# RIGHT SIDE PROMPT
[[blocks]]
type = "rprompt"
alignment = "right"
[[blocks.segments]]
template = " {{ .Full }}"
foreground = "p:gb_faded_green"
background = "transparent"
type = "node"
style = "plain"
[blocks.segments.properties]
display_mode = "files"
[[blocks.segments]]
template = " {{ if .Venv }}({{ .Venv }}) {{ end }}{{ .Full }}"
foreground = "p:gb_faded_green"
background = "transparent"
type = "python"
style = "plain"
[blocks.segments.properties]
display_mode = "always"
fetch_virtual_env = true
# NEWLINE FOR INPUT
[[blocks]]
type = "prompt"
alignment = "left"
newline = true
[[blocks.segments]]
template = "❯ "
foreground = "p:gb_bright_aqua"
background = "transparent"
type = "text"
style = "plain"
+45
View File
@@ -38,5 +38,50 @@ use = "yazi-rs/plugins:chmod"
rev = "c591a36" rev = "c591a36"
hash = "87472b05a8c420100f6a2b9cde1e7746" hash = "87472b05a8c420100f6a2b9cde1e7746"
[[plugin.deps]]
use = "XYenon/yafg"
rev = "e6ba851"
hash = "9558dd9169cbf01eac6044583c426716"
[[plugin.deps]]
use = "MasouShizuka/projects"
rev = "22a4006"
hash = "195d1b8c8fc1a944883b5ce3d92d7ca7"
[[plugin.deps]]
use = "MasouShizuka/close-and-restore-tab"
rev = "b2153bc"
hash = "1493e40f8f4f222c9ecb24cf85ccabd2"
[[plugin.deps]]
use = "Lil-Dank/lazygit"
rev = "e73fd74"
hash = "6ea5f37c7f219671ec504cb8311f889d"
[[plugin.deps]]
use = "yazi-rs/plugins:git"
rev = "c591a36"
hash = "5bb0bfab901d3601c370eafdd66edd31"
[[plugin.deps]]
use = "llanosrocas/yaziline"
rev = "029b27d"
hash = "ceeb45e796faf0d9eed10831ffec7701"
[[plugin.deps]]
use = "boydaihungst/file-extra-metadata"
rev = "8bb639d"
hash = "8c5f14c09c981a496afaab5184e4aa08"
[[plugin.deps]]
use = "Sonico98/exifaudio"
rev = "4506f9d"
hash = "4761fffb60a12d37096c34a356380cdf"
[[plugin.deps]]
use = "goon/omni-trash"
rev = "3c2a992"
hash = "6e5bf967707c8c9b6495cf5863ff497f"
[flavor] [flavor]
deps = [] deps = []
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 MasouShizuka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,49 @@
# close-and-restore-tab.yazi
A [Yazi](https://github.com/sxyazi/yazi) plugin that adds the functionality to restore closed tabs.
## Features
- Remember a tab's working directory and position when it is closed.
- Restore any closed tab at its previous position.
## Installation
```sh
ya pkg add MasouShizuka/close-and-restore-tab
# or
# Windows
git clone https://github.com/MasouShizuka/close-and-restore-tab.yazi.git %AppData%\yazi\config\plugins\close-and-restore-tab.yazi
# Linux/macOS
git clone https://github.com/MasouShizuka/close-and-restore-tab.yazi.git ~/.config/yazi/plugins/close-and-restore-tab.yazi
```
Then add the plugin's `setup` function in Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`.
```lua
require("close-and-restore-tab"):setup()
```
## Keymap
Add this to your `keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = [ "<C-t>" ]
run = "plugin close-and-restore-tab restore"
desc = "Restore the previously closed tab"
```
If you want to use a non-default binding to close the current tab,
which is bound to `<C-c>`:
```toml
[[mgr.prepend_keymap]]
on = "<C-w>"
run = "close"
desc = "Close the current tab, or quit if it's last"
```
@@ -0,0 +1,72 @@
--- @since 26.5.1
-- Requires `key-close` event from https://github.com/sxyazi/yazi/commit/740d8919896542de18db0c5da5fb347a14459890.
local _get_closed_tabs = ya.sync(function(state)
return state.closed_tabs or {}
end)
local _save_closed_tab = ya.sync(function(state)
local closed_tabs = _get_closed_tabs()
-- TODO: add more tab properties
local tab = {
idx = tonumber(cx.tabs.idx) - 1,
cwd = tostring(cx.active.current.cwd),
}
closed_tabs[#closed_tabs + 1] = tab
ya.dbg("Recorded closed tab", tab)
state.closed_tabs = closed_tabs
end)
local restore = ya.sync(function(state)
local closed_tabs = _get_closed_tabs()
if #closed_tabs == 0 then
ya.notify {
title = "No tabs!",
content = "No more tabs to restore",
timeout = 4,
}
return
end
local tab = closed_tabs[#closed_tabs]
ya.dbg("Restoring tab", tab)
table.remove(closed_tabs, #closed_tabs)
state.closed_tabs = closed_tabs
local idx = tab.idx
if idx == 0 then
ya.emit("tab_switch", { 0 })
else
ya.emit("tab_switch", { idx - 1 })
end
-- TODO: add more tab properties to restore
ya.emit("tab_create", { tab.cwd })
if idx == 0 then
ya.emit("tab_swap", { -1 })
end
end)
return {
setup = function()
ps.sub("key-close", function(args)
if #cx.tabs ~= 1 then
_save_closed_tab()
end
return args
end)
end,
entry = function(_, job)
local action = job.args[1]
if action == "restore" then
restore()
return
end
end,
}
Submodule yazi/.config/yazi/plugins/current-size.yazi added at f2c4725468.
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Sonico98
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,38 @@
# exifaudio.yazi
Preview audio metadata and cover on [Yazi](https://github.com/sxyazi/yazi).
![image](https://github.com/Sonico98/exifaudio.yazi/assets/61394886/53c1492c-9f05-4c80-a4e7-94fb36f35ca9)
## Installation
```sh
# Automatically with yazi 0.3.0
ya pack -a "Sonico98/exifaudio"
# Or manually under:
# Linux/macOS
git clone https://github.com/Sonico98/exifaudio.yazi.git ~/.config/yazi/plugins/exifaudio.yazi
# Windows
git clone https://github.com/Sonico98/exifaudio.yazi.git %AppData%\yazi\config\plugins\exifaudio.yazi
```
## Usage
Add the following to your `yazi.toml`:
```toml
[plugin]
prepend_previewers = [
{ mime = "audio/*", run = "exifaudio"}
]
```
Make sure you have [exiftool](https://exiftool.org/) installed and in your `PATH`.
Optional: if you have [mediainfo](https://mediaarea.net/en/MediaInfo) installed and in your `PATH`, it will be used instead for more accurate metadata. Exiftool is still required to display the cover.
## Thanks
Thanks to [sxyazi](https://github.com/sxyazi) for the PDF previewer code, on which this previewer is based on.
@@ -0,0 +1,215 @@
local M = {}
function GetPath(str)
local sep = '/'
if ya.target_family() == "windows" then
sep = '\\'
end
return str:match("(.*"..sep..")")
end
function Exiftool(...)
local child = Command("exiftool")
:arg{
"-q", "-q", "-S", "-Title", "-SortName",
"-TitleSort", "-TitleSortOrder", "-Artist",
"-SortArtist", "-ArtistSort", "-PerformerSortOrder",
"-Album", "-SortAlbum", "-AlbumSort", "-AlbumSortOrder",
"-AlbumArtist", "-SortAlbumArtist", "-AlbumArtistSort",
"-AlbumArtistSortOrder", "-Genre", "-TrackNumber",
"-Year", "-Duration", "-SampleRate",
"-AudioSampleRate", "-AudioBitrate", "-AvgBitrate",
"-Channels", "-AudioChannels", tostring(...),
}
:stdout(Command.PIPED)
:stderr(Command.NULL)
:spawn()
return child
end
function Mediainfo(...)
local file, cache_dir = ...
local template = cache_dir.."mediainfo.txt"
local child = Command("mediainfo")
:arg{
"--Output=file://"..template, tostring(file)
}
:stdout(Command.PIPED)
:stderr(Command.NULL)
:spawn()
return child
end
function M:peek(job)
local cache = ya.file_cache(job)
if not cache then
return
end
-- Get cache dir to find the mediainfo template file
local cache_dir = GetPath(tostring(cache))
-- Try mediainfo, otherwise use exiftool
local status, child = pcall(Mediainfo, job.file.url, cache_dir)
if not status or child == nil then
status, child = pcall(Exiftool, job.file.url)
if not status or child == nil then
local error = ui.Line { ui.Span("Make sure exiftool is installed and in your PATH") }
local p = ui.Text(error):area(job.area):wrap(ui.Wrap.YES)
ya.preview_widget(job, { p })
return
end
end
local limit = job.area.h
local i, metadata = 0, {}
repeat
local next, event = child:read_line()
if event == 1 then
return self:fallback_to_builtin()
elseif event ~= 0 then
break
end
i = i + 1
if i > job.skip then
local m_title, m_tag = Prettify(next)
if m_title ~= "" and m_tag ~= "" then
local ti = ui.Span(m_title):bold()
local ta = ui.Span(m_tag)
table.insert(metadata, ui.Line{ti, ta})
table.insert(metadata, ui.Line{})
end
end
until i >= job.skip + limit
local p = ui.Text(metadata):area(job.area):wrap(ui.Wrap.YES)
ya.preview_widget(job, { p })
local cover_width = job.area.w / 2 - 5
local cover_height = (job.area.h / 4) + 3
local bottom_right = ui.Rect {
x = job.area.right - cover_width,
y = job.area.bottom - cover_height,
w = cover_width,
h = cover_height,
}
if self:preload(job) == true then
ya.image_show(cache, bottom_right)
end
end
function Prettify(metadata)
local substitutions = {
Sortname = "Sort Title:",
SortName = "Sort Title:",
TitleSort = "Sort Title:",
TitleSortOrder = "Sort Title:",
ArtistSort = "Sort Artist:",
SortArtist = "Sort Artist:",
Artist = "Artist:",
ARTIST = "Artist:",
PerformerSortOrder = "Sort Artist:",
SortAlbumArtist = "Sort Album Artist:",
AlbumArtistSortOrder = "Sort Album Artist:",
AlbumArtistSort = "Sort Album Artist:",
AlbumSortOrder = "Sort Album:",
AlbumSort = "Sort Album:",
SortAlbum = "Sort Album:",
Album = "Album:",
ALBUM = "Album:",
AlbumArtist = "Album Artist:",
Genre = "Genre:",
GENRE = "Genre:",
TrackNumber = "Track Number:",
Year = "Year:",
Duration = "Duration:",
AudioBitrate = "Bitrate:",
AvgBitrate = "Average Bitrate:",
AudioSampleRate = "Sample Rate:",
SampleRate = "Sample Rate:",
AudioChannels = "Channels:"
}
for k, v in pairs(substitutions) do
metadata = metadata:gsub(tostring(k)..":", v, 1)
end
-- Separate the tag title from the tag data
local t={}
for str in string.gmatch(metadata , "([^"..":".."]+)") do
if str ~= "\n" then
table.insert(t, str)
else
table.insert(t, nil)
end
end
-- Add back semicolon to title, rejoin tag data if it happened to contain a semicolon
local title, tag_data = "", ""
if t[1] ~= nil then
title, tag_data = t[1]..":", table.concat(t, ":", 2)
end
return title, tag_data
end
function M:seek(job)
local h = cx.active.current.hovered
if h and h.url == job.file.url then
ya.manager_emit("peek", {
tostring(math.max(0, cx.active.preview.skip + job.units)),
only_if = tostring(job.file.url),
})
end
end
function M:preload(job)
local cache = ya.file_cache(job)
if not cache or fs.cha(cache) then
return true
end
local mediainfo_template = 'General;"\
$if(%Track%,Title: %Track%,)\
$if(%Track/Sort%,Sort Title: %Track/Sort%,)\
$if(%Title/Sort%,Sort Title: %Title/Sort%,)\
$if(%TITLESORT%,Sort Title: %TITLESORT%,)\
$if(%Performer%,Artist: %Performer%,)\
$if(%Performer/Sort%,Sort Artist: %Performer/Sort%,)\
$if(%ARTISTSORT%,Sort Artist: %ARTISTSORT%,)\
$if(%Album%,Album: %Album%,)\
$if(%Album/Sort%,Sort Album: %Album/Sort%)\
$if(%ALBUMSORT%,Sort Album: %ALBUMSORT%)\
$if(%Album/Performer%,Album Artist: %Album/Performer%)\
$if(%Album/Performer/Sort%,Sort Album Artist: %Album/Performer/Sort%)\
$if(%Genre%,Genre: %Genre%)\
$if(%Track/Position%,Track Number: %Track/Position%)\
$if(%Recorded_Date%,Year: %Recorded_Date%)\
$if(%Duration/String%,Duration: %Duration/String%)\
$if(%BitRate/String%,Bitrate: %BitRate/String%)\
"\
Audio;"Sample Rate: %SamplingRate%\
Channels: %Channel(s)%"\
'
-- Write the mediainfo template file into yazi's cache dir
local cache_dir = GetPath(tostring(cache))
fs.write(Url(cache_dir.."mediainfo.txt"), mediainfo_template)
local output = Command("exiftool")
:arg{ "-b", "-CoverArt", "-Picture", tostring(job.file.url) }
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:output()
if not output then
return true, Err("Couldn't extract cover art, error: %s", err)
end
return fs.write(cache, output.stdout) and true or false
end
return M
@@ -0,0 +1,19 @@
Copyright (c) 2024 boydaihungst
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,110 @@
# file-extra-metadata
<!--toc:start-->
- [file-extra-metadata](#file-extra-metadata)
- [Preview](#preview)
- [Before:](#before)
- [After:](#after)
- [Requirements](#requirements)
- [Installation](#installation)
- [For developer](#for-developer)
<!--toc:end-->
This is a Yazi plugin that replaces the default file previewer and spotter with extra information.
> [!IMPORTANT]
> Minimum version: yazi v26.5.6
## Preview
### Before:
- Previewer
![Before preview](statics/2024-11-17-12-06-24.png)
- Spotter
![Before spot](statics/2025-12-29-before_spotter.png)
### After:
- Previewer
![After previewer](statics/2024-11-21-05-27-48.png)
- Spotter
![After spotter](statics/2025-12-29-after_spotter.png)
## Requirements
- [yazi >= 26.5.6](https://github.com/sxyazi/yazi)
- Tested on Linux. For MacOS, Windows: some fields will shows empty values.
## Installation
Install the plugin:
```sh
ya pkg add boydaihungst/file-extra-metadata
```
Create `~/.config/yazi/yazi.toml` and add:
For yazi < v25.12.29 (29/12/2025) replace `url` with `name`
```toml
[plugin]
append_previewers = [
{ url = "*", run = "file-extra-metadata" },
]
# Setup keybind for spotter: https://github.com/sxyazi/yazi/pull/1802
append_spotters = [
{ url = "*", run = "file-extra-metadata" },
]
```
or
```toml
[plugin]
previewers = [
# ... the rest
# disable default file plugin { name = "*", run = "file" },
{ url = "*", run = "file-extra-metadata" },
]
# Setup keybind for spotter: https://github.com/sxyazi/yazi/pull/1802
spotters = [
# ... the rest
# Fallback
# { name = "*", run = "file" },
{ url = "*", run = "file-extra-metadata" },
]
```
### Custom theme
Read more: https://github.com/sxyazi/yazi/pull/2391
Edit or add `yazi/theme.toml`:
```toml
[spot]
border = { fg = "#4fa6ed" }
title = { fg = "#4fa6ed" }
# Table.
tbl_cell = { fg = "#4fa6ed", reversed = true }
tbl_col = { fg = "#4fa6ed" }
```
## For developer
If you want to combine this with other spotter/previewer:
```lua
require("file-extra-metadata"):render_table(job, { show_plugins_section = true })
```
@@ -0,0 +1,414 @@
--- @since 26.5.6
local M = {}
local STATE_KEY = {
ALTER_DF_COMMAND = "ALTER_DF_COMMAND",
}
local set_state = ya.sync(function(state, key, value)
state[key] = value
end)
local get_state = ya.sync(function(state, key)
return state[key]
end)
local function permission(file)
local h = file
if not h then
return ""
end
local perm = h.cha:perm()
if not perm then
return ""
end
local spans = ""
for i = 1, #perm do
local c = perm:sub(i, i)
spans = spans .. c
end
return spans
end
local function link_count(file)
local h = file
if h == nil or ya.target_family() ~= "unix" then
return ""
end
return h.cha.nlink
end
local function owner_group(file)
local h = file
if h == nil or ya.target_family() ~= "unix" then
return ""
end
return (ya.user_name(h.cha.uid) or tostring(h.cha.uid)) .. "/" .. (ya.group_name(h.cha.gid) or tostring(h.cha.gid))
end
local file_size_and_folder_childs = function(file)
local h = file
if not h then
return ""
end
return h.cha.len and ya.readable_size(h.cha.len) or ""
end
--- get file timestamp
---@param file any
---@param type "mtime" | "atime" | "btime"
---@return any
local function fileTimestamp(file, type)
local h = file
if not h then
return ""
end
local time = math.floor(h.cha[type] or 0)
if time == 0 then
return ""
else
return os.date("%Y-%m-%d %H:%M", time)
end
end
-- Function to split a string by spaces (considering multiple spaces as one delimiter)
local function split_by_whitespace(input)
local result = {}
for word in string.gmatch(input, "%S+") do
table.insert(result, word)
end
return result
end
local function get_filesystem_extra(file)
local result = {
filesystem = "",
device = "",
type = "",
used_space = "",
avail_space = "",
total_space = "",
used_space_percent = "",
avail_space_percent = "",
error = nil,
is_virtual = false,
}
local h = file
local file_url = h.url
local is_virtual
if not file_url.spec then
is_virtual = file_url.scheme and file_url.scheme.is_virtual
file_url = is_virtual
and (file.path or Url(file_url.scheme and file_url.scheme.cache .. tostring(file_url.path)))
or file_url
else
is_virtual = file_url.spec and file_url.spec.is_virtual
file_url = is_virtual and file.path or file_url
end
if not h or ya.target_family() ~= "unix" then
return result
end
local output, child
local alter_df_command = get_state(STATE_KEY.ALTER_DF_COMMAND)
if not alter_df_command then
child, _ = Command("df"):arg({ "-P", "-T", "-h", tostring(file_url) }):stdout(Command.PIPED):spawn()
if child then
-- Ignore header
local _, event = child:read_line()
if event == 0 then
output, _ = child:read_line()
end
child:start_kill()
end
end
-- Fallback for macOS/BSD if -T failed (empty output or error)
if not output or output == "" then
if not alter_df_command then
set_state(STATE_KEY.ALTER_DF_COMMAND, true)
end
child, _ = Command("df"):arg({ "-P", "-h", tostring(file_url) }):stdout(Command.PIPED):spawn()
if child then
local _, event = child:read_line() -- skip header
if event == 0 then
output, _ = child:read_line()
end
child:start_kill()
end
end
if output and output ~= "" then
-- Splitting the data
local parts = split_by_whitespace(output)
-- Display the result
if #parts >= 7 then
result.filesystem = is_virtual and (parts[7] .. " (vfs)") or parts[7]
result.device = is_virtual and (parts[1] .. " (vfs)") or parts[1]
result.total_space = parts[3]
result.used_space = parts[4]
result.avail_space = parts[5]
result.used_space_percent = parts[6]
result.avail_space_percent = 100 - tonumber((string.match(parts[6], "%d+") or "0"))
result.type = is_virtual and (parts[2] .. " (vfs)") or parts[2]
else
result.filesystem = is_virtual and (parts[6] .. " (vfs)") or parts[6]
-- result.device (Type) is missing in df output, fetch from mount
result.total_space = parts[2]
result.used_space = parts[3]
result.avail_space = parts[4]
result.used_space_percent = parts[5]
result.avail_space_percent = 100 - tonumber((string.match(parts[5], "%d+") or "0"))
result.device = is_virtual and (parts[1] .. " (vfs)") or parts[1]
local mount_child = Command("mount"):stdout(Command.PIPED):spawn()
if mount_child then
while true do
local line, event = mount_child:read_line()
if not line or event ~= 0 then
break
end
-- Check if line starts with filesystem (e.g. /dev/disk1s1 on ...)
local s, e = line:find(parts[1] .. " on ", 1, true)
if s == 1 then
local fstype = line:match("%(([^,]+)")
if fstype then
result.type = is_virtual and (fstype .. " (vfs)") or fstype
end
break
end
end
end
end
result.is_virtual = is_virtual
else
result.error = "df error: check install"
end
return result
end
local function attributes(file)
local h = file
local file_url = h.url
if h.cha.is_link then
file_url = Url(h.link_to)
end
local is_virtual
if not file_url.spec then
is_virtual = file_url.scheme and file_url.scheme.is_virtual
file_url = is_virtual
and (file.path or Url(file_url.scheme and file_url.scheme.cache .. tostring(file_url.path)))
or file_url
else
is_virtual = file_url.spec and file_url.spec.is_virtual
file_url = is_virtual and file.path or file_url
end
if not h or ya.target_family() ~= "unix" then
return ""
end
local output, _ = Command("lsattr"):arg({ "-d", tostring(file_url) }):stdout(Command.PIPED):output()
if output then
-- Splitting the data
local parts = split_by_whitespace(output.stdout)
-- Display the result
for i, part in ipairs(parts) do
if i == 1 then
return part
end
end
return ""
else
return "lsattr error: check install"
end
end
---shorten string
---@param _s string string
---@param _t string tail
---@param _w number max characters
---@return string
local shorten = function(_s, _t, _w)
local s = _s or utf8.len(_s)
local t = _t or ""
local ellipsis = "…" .. t
local w = _w < utf8.len(ellipsis) and utf8.len(ellipsis) or _w
local n_ellipsis = utf8.len(ellipsis) or 0
if utf8.len(s) > w then
return s:sub(1, (utf8.offset(s, w - n_ellipsis + 1) or 2) - 1) .. ellipsis
end
return s
end
function M:render_table(job, opts)
local styles = {
header = th.spot.title or ui.Style():fg("green"),
row_label = ui.Style():fg("reset"),
row_value = th.spot.tbl_col or ui.Style():fg("blue"),
}
local filesystem_extra = get_filesystem_extra(job.file)
local prefix = " "
local rows = {}
local label_max_length = 15
local file_name_extension = job.file.cha.is_dir and "…" or ("." .. (job.file.url.ext or ""))
local row = function(key, value)
local h = type(value) == "table" and #value or 1
rows[#rows + 1] = ui.Row({ ui.Line(key):style(styles.row_label), ui.Text(value):style(styles.row_value) })
:height(h)
end
local file_name = shorten(
job.file.name,
file_name_extension,
math.floor(job.area.w - label_max_length - utf8.len(file_name_extension))
)
local location = shorten(
tostring((job.file.url.path or job.file.url).parent),
"",
math.floor(job.area.w - label_max_length - utf8.len(prefix))
)
local filesystem_error = filesystem_extra.error
and shorten(filesystem_extra.error, "", math.floor(job.area.w - label_max_length - utf8.len(prefix)))
or nil
local filesystem =
shorten(filesystem_extra.filesystem, "", math.floor(job.area.w - label_max_length - utf8.len(prefix)))
rows[#rows + 1] = ui.Row({ "Metadata", "" }):style(styles.header)
row(prefix .. "File:", file_name)
row(prefix .. "Mimetype:", job.mime)
row(prefix .. "Location:", location)
if job.file.cache then
row(prefix .. "Cached:", tostring(job.file.path or job.file.cache))
end
row(prefix .. "Mode:", permission(job.file))
row(prefix .. "Attributes:", attributes(job.file))
row(prefix .. "Links:", tostring(link_count(job.file)))
if job.file.cha.is_link then
row(prefix .. "Linked:", tostring(job.file.cha.is_link and job.file.link_to))
end
row(prefix .. "Owner:", owner_group(job.file))
row(prefix .. "Size:", file_size_and_folder_childs(job.file))
row(prefix .. "Created:", fileTimestamp(job.file, "btime"))
row(prefix .. "Modified:", fileTimestamp(job.file, "mtime"))
row(prefix .. "Accessed:", fileTimestamp(job.file, "atime"))
row(prefix .. "Filesystem:", filesystem_error or filesystem)
row(prefix .. "Device:", filesystem_error or filesystem_extra.device)
row(prefix .. "Type:", filesystem_error or filesystem_extra.type)
row(
prefix .. "Free space:",
filesystem_error
or (
(
filesystem_extra.avail_space
and filesystem_extra.total_space
and filesystem_extra.avail_space_percent
)
and (filesystem_extra.avail_space .. " / " .. filesystem_extra.total_space .. " (" .. filesystem_extra.avail_space_percent .. "%)")
or ""
)
)
if opts and opts.show_plugins_section then
-- TODO: Remove this after the next release
local spotter, previewer, fetchers, preloaders = nil, nil, {}, {}
rows[#rows + 1] = ui.Row({ { "", "Plugins" }, "" }):height(2):style(styles.header)
if type(rt.plugin.spotters.match) ~= "nil" then
local pair = { file = job.file, mime = job.mime }
for _, v in pairs(rt.plugin.spotters:match(pair)) do
spotter = v
break
end
for _, v in pairs(rt.plugin.previewers:match(pair)) do
previewer = v
break
end
for _, v in pairs(rt.plugin.fetchers:match(pair)) do
fetchers[#fetchers + 1] = v.name
end
fetchers = #fetchers ~= 0 and fetchers or { "(none)" }
for _, v in pairs(rt.plugin.preloaders:match(pair)) do
preloaders[#preloaders + 1] = v.name
end
preloaders = #preloaders ~= 0 and preloaders or { "(none)" }
row(prefix .. "Spotter:", spotter and spotter.name or "(none)")
row(prefix .. "Previewer:", previewer and previewer.name or "(none)")
row(prefix .. "Fetchers:", fetchers)
row(prefix .. "Preloaders:", preloaders)
else
local is_yazi_nightly, _ = pcall(require, "mime.dir")
spotter = rt.plugin.spotter(is_yazi_nightly and job.file or job.file.url, job.mime)
previewer = rt.plugin.previewer(is_yazi_nightly and job.file or job.file.url, job.mime)
fetchers = rt.plugin.fetchers(job.file, job.mime)
preloaders = rt.plugin.preloaders(is_yazi_nightly and job.file or job.file.url, job.mime)
for i, v in ipairs(fetchers) do
fetchers[i] = v.cmd
end
for i, v in ipairs(preloaders) do
preloaders[i] = v.cmd
end
row(prefix .. "Spotter:", spotter and spotter.cmd or "(none)")
row(prefix .. "Previewer:", previewer and previewer.cmd or "(none)")
row(prefix .. "Fetchers:", #fetchers ~= 0 and fetchers or "(none)")
row(prefix .. "Preloaders:", #preloaders ~= 0 and preloaders or "(none)")
end
end
return ui.Table(rows):area(job.area):row(1):col(1):col_style(styles.row_value):widths({
ui.Constraint.Length(label_max_length),
ui.Constraint.Fill(1),
})
end
function M:peek(job)
local start, cache = os.clock(), ya.file_cache(job)
if not cache or not self:preload(job) then
return 1
end
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
ya.preview_widget(job, { self:render_table(job) })
end
function M:seek(job)
local h = cx.active.current.hovered
if h and h.url == job.file.url then
local step = math.floor(job.units * job.area.h / 10)
ya.emit("peek", {
tostring(math.max(0, cx.active.preview.skip + step)),
only_if = tostring(job.file.url),
})
end
end
function M:preload(job)
local cache = ya.file_cache(job)
if not cache or fs.cha(cache) then
return true
end
return true
end
function M:spot(job)
job.area = ui.Pos({ "center", w = 80, h = 25 })
ya.spot_table(
job,
self:render_table(job, { show_plugins_section = true })
:cell_style(th.spot.tbl_cell or ui.Style():fg("blue"):reverse())
)
end
return M
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 yazi-rs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,86 @@
# git.yazi
Show the status of Git file changes as linemode in the file list.
https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576
## Installation
```sh
ya pkg add yazi-rs/plugins:git
```
## Setup
Add the following to your `~/.config/yazi/init.lua`:
```lua
require("git"):setup {
-- Order of status signs showing in the linemode
order = 1500,
}
```
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
```toml
[[plugin.prepend_fetchers]]
url = "*"
run = "git"
group = "git"
[[plugin.prepend_fetchers]]
url = "*/"
run = "git"
group = "git"
```
## Advanced
You can customize the [Style](https://yazi-rs.github.io/docs/configuration/theme#types.style) of the status sign with:
- `[git].unknown` - status cannot/not yet determined
- `[git].ignored` - ignored file
- `[git].untracked` - untracked file
- `[git].unstaged` - unstaged file
- `[git].staged` - staged file
- `[git].added` - staged new file
- `[git].deleted` - deleted file
- `[git].updated` - updated file
- `[git].clean` - clean file
For example:
```toml
# theme.toml / flavor.toml
[git]
unstaged = { fg = "blue" }
deleted = { fg = "red", bold = true }
```
You can also customize the text of the status sign with:
- `[git].unknown_sign` - status cannot/not yet determined
- `[git].ignored_sign` - ignored file
- `[git].untracked_sign` - untracked file
- `[git].unstaged_sign` - unstaged file
- `[git].staged_sign` - staged file
- `[git].added_sign` - staged new file
- `[git].deleted_sign` - deleted file
- `[git].updated_sign` - updated file
- `[git].clean_sign` - clean file
For example:
```toml
# theme.toml / flavor.toml
[git]
unknown_sign = " "
unstaged_sign = "M"
deleted_sign = "D"
clean_sign = "✔"
```
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
+279
View File
@@ -0,0 +1,279 @@
--- @since 26.8.15
local WINDOWS = ya.target_family() == "windows"
-- The code of supported git status,
-- also used to determine which status to show for directories when they contain different statuses
-- see `bubble_up`
---@enum CODES
local CODES = {
unknown = 100, -- status cannot/not yet determined
excluded = 99, -- ignored directory
ignored = 7, -- ignored file
untracked = 6,
unstaged = 5,
staged = 4,
added = 3,
deleted = 2,
updated = 1,
clean = 0,
}
local PATTERNS = {
{ "!$", CODES.ignored },
{ "?$", CODES.untracked },
{ ".[MT]", CODES.unstaged },
{ "[MT] ", CODES.staged },
{ "[AC]", CODES.added },
{ "D", CODES.deleted },
{ "U", CODES.updated },
{ "[AD][AD]", CODES.updated },
}
local function theme()
local t = th.git or {}
return {
[CODES.unknown] = t.unknown or ui.Style(),
[CODES.ignored] = t.ignored or ui.Style():fg("darkgray"),
[CODES.untracked] = t.untracked or ui.Style():fg("magenta"),
[CODES.unstaged] = t.unstaged or ui.Style():fg("yellow"),
[CODES.staged] = t.staged or ui.Style():fg("green"),
[CODES.added] = t.added or ui.Style():fg("green"),
[CODES.deleted] = t.deleted or ui.Style():fg("red"),
[CODES.updated] = t.updated or ui.Style():fg("yellow"),
[CODES.clean] = t.clean or ui.Style(),
}, {
[CODES.unknown] = t.unknown_sign or "",
[CODES.ignored] = t.ignored_sign or "",
[CODES.untracked] = t.untracked_sign or "? ",
[CODES.unstaged] = t.unstaged_sign or "",
[CODES.staged] = t.staged_sign or "",
[CODES.added] = t.added_sign or "",
[CODES.deleted] = t.deleted_sign or "",
[CODES.updated] = t.updated_sign or "",
[CODES.clean] = t.clean_sign or "",
}
end
---@param line string
---@return CODES, string
local function match(line)
local signs = line:sub(1, 2)
for _, p in ipairs(PATTERNS) do
local path, pattern, code = nil, p[1], p[2]
if signs:find(pattern) then
path = line:sub(4, 4) == '"' and line:sub(5, -2) or line:sub(4)
path = WINDOWS and path:gsub("/", "\\") or path
end
if not path then
elseif path:find("[/\\]$") then
-- Mark the ignored directory as `excluded`, so we can process it further within `propagate_down`
return code == CODES.ignored and CODES.excluded or code, path:sub(1, -2)
else
return code, path
end
---@diagnostic disable-next-line: missing-return
end
end
---@param cwd Url
---@return string?
local function root(cwd)
local is_worktree = function(url)
local file, head = io.open(tostring(url)), nil
if file then
head = file:read(8)
file:close()
end
return head == "gitdir: "
end
repeat
local next = cwd:join(".git")
local cha = fs.cha(next)
if cha and (cha.is_dir or is_worktree(next)) then
return tostring(cwd)
end
cwd = cwd.parent
until not cwd
end
---@type UnstableFetcher
local function retry(job)
return ya.co(function()
for _, file in ipairs(job.files) do
coroutine.yield(file, { retry = true })
end
end)
end
---@param changed Changes
---@return Changes
local function bubble_up(changed)
local new, empty = {}, Url("")
for path, code in pairs(changed) do
if code ~= CODES.ignored then
local url = Url(path).parent
while url and url ~= empty do
local s = tostring(url)
new[s] = (new[s] or CODES.clean) > code and new[s] or code
url = url.parent
end
end
end
return new
end
---@param excluded string[]
---@param cwd Url
---@param repo Url
---@return Changes
local function propagate_down(excluded, cwd, repo)
local new, rel = {}, cwd:strip_prefix(repo)
for _, path in ipairs(excluded) do
if rel:starts_with(path) then
-- If `cwd` is a subdirectory of an excluded directory, also mark it as `excluded`
new[tostring(cwd)] = CODES.excluded
elseif cwd == repo:join(path).parent then
-- If `path` is a direct subdirectory of `cwd`, mark it as `ignored`
new[path] = CODES.ignored
else
-- Skipping, we only care about `cwd` itself and its direct subdirectories for maximum performance
end
end
return new
end
---@param cwd string
---@param repo string
---@param changed Changes
local add = ya.sync(function(st, cwd, repo, changed)
---@cast st State
st.dirs[cwd] = repo
st.repos[repo] = st.repos[repo] or {}
for path, code in pairs(changed) do
if code == CODES.clean then
st.repos[repo][path] = nil
elseif code == CODES.excluded then
-- Mark the directory with a special value `excluded` so that it can be distinguished during UI rendering
st.dirs[path] = CODES.excluded
else
st.repos[repo][path] = code
end
end
ui.render()
end)
---@param cwd string
local remove = ya.sync(function(st, cwd)
---@cast st State
local repo = st.dirs[cwd]
if not repo then
return
end
ui.render()
st.dirs[cwd] = nil
if not st.repos[repo] then
return
end
for _, r in pairs(st.dirs) do
if r == repo then
return
end
end
st.repos[repo] = nil
end)
---@param st State
---@param opts Options
local function setup(st, opts)
st.dirs = {}
st.repos = {}
opts = opts or {}
opts.order = opts.order or 1500
local styles, signs = theme()
ps.sub("theme", function()
styles, signs = theme()
end)
Linemode:children_add(function(self)
if not self._file.in_current then
return ""
end
local url = self._file.url
local repo = st.dirs[tostring(url.base or url.parent)]
local code = CODES.unknown
if repo then
code = repo == CODES.excluded and CODES.ignored or st.repos[repo][tostring(url):sub(#repo + 2)] or CODES.clean
end
if signs[code] == "" then
return ""
elseif self._file.is_hovered then
return ui.Line { " ", signs[code] }
else
return ui.Line { " ", ui.Span(signs[code]):style(styles[code]) }
end
end, opts.order)
end
---@type UnstableFetcher
local function fetch(_, job)
local cwd = job.files[1].url.base or job.files[1].url.parent
local repo = root(cwd)
if not repo then
remove(tostring(cwd))
return require("noop"):fetch(job)
end
local paths = {}
for _, file in ipairs(job.files) do
paths[#paths + 1] = tostring(file.url)
end
-- stylua: ignore
local output, err = Command("git")
:cwd(tostring(cwd))
:arg({ "--no-optional-locks", "-c", "core.quotePath=", "status", "--porcelain", "-unormal", "--no-renames", "--ignored=matching" })
:arg(paths)
:output()
if not output then
ya.err("Cannot spawn `git` command, error: " .. err)
return require("noop"):fetch(job)
end
local changed, excluded = {}, {}
for line in output.stdout:gmatch("[^\r\n]+") do
local code, path = match(line)
if code == CODES.excluded then
excluded[#excluded + 1] = path
else
changed[path] = code
end
end
if job.files[1].cha.is_dir then
ya.dict_merge(changed, bubble_up(changed))
end
ya.dict_merge(changed, propagate_down(excluded, cwd, Url(repo)))
-- Reset the status of any files that don't appear in the output of `git status` to `clean`,
-- so that cleaning up outdated statuses from `st.repos`
for _, path in ipairs(paths) do
local s = path:sub(#repo + 2)
changed[s] = changed[s] or CODES.clean
end
add(tostring(cwd), repo, changed)
return retry(job)
end
return { setup = setup, fetch = fetch }
@@ -0,0 +1,12 @@
---@class State
---@field dirs table<string, string|CODES> Mapping between a directory and its corresponding repository
---@field repos table<string, Changes> Mapping between a repository and the status of each of its files
---@class Options
---@field order number The order in which the status is displayed
---@field renamed boolean Whether to include renamed files in the status (or treat them as unstaged)
-- TODO: move this to `types.yazi` once it's get stable
---@alias UnstableFetcher fun(self: unknown, job: { files: File[] })
---@alias Changes table<string, CODES>
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Darius
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,31 @@
# lazygit.yazi
Plugin for [Yazi](https://github.com/sxyazi/yazi) to manage git repos with [lazygit](https://github.com/jesseduffield/lazygit)
## Dependencies
Make sure [lazygit](https://github.com/jesseduffield/lazygit) is installed and in your `PATH`.
## Installation
### Using `ya pkg`
```
ya pkg add Lil-Dank/lazygit
```
### Manual
**Linux/macOS**
```
git clone https://github.com/Lil-Dank/lazygit.yazi.git ~/.config/yazi/plugins/lazygit.yazi
```
**Windows**
```
git clone https://github.com/Lil-Dank/lazygit.yazi.git %AppData%\yazi\config\plugins\lazygit.yazi
```
## Configuration
add this to your **keymap.toml** file
```toml
[[mgr.prepend_keymap]]
on = [ "g", "i" ]
run = "plugin lazygit"
desc = "run lazygit"
```
you can customize the keybinding however you like. Please refer to the [keymap.toml](https://yazi-rs.github.io/docs/configuration/keymap) documentation
## Disclaimer
**THIS PLUGIN IS FOR THE STABLE RELEASE OF YAZI, DON'T PROPOSE ANY CHANGES BASED ON PRE-RELEASES OF YAZI**
@@ -0,0 +1,19 @@
return {
entry = function()
local output = Command("git"):arg("status"):stderr(Command.PIPED):output()
if output.stderr ~= "" then
ya.notify({
title = "lazygit",
content = "Not in a git directory\nError: " .. output.stderr,
level = "warn",
timeout = 5,
})
else
ya.emit("shell", {
"lazygit",
block = true,
confirm = false,
})
end
end,
}
Submodule yazi/.config/yazi/plugins/lsblk-mount.yazi added at 73e863ff4f.
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Goon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,58 @@
# omni-trash.yazi
<div align="center">
[Yazi](https://yazi-rs.github.io/) plugin to manage your trash across **all drives** from a single, unified interface, powered by [`trash-cli`](https://github.com/andreafrancia/trash-cli).
![preview](preview.png)
</div>
## Features
- **Unified View** — See trashed files from your home drive and all mounted volumes (`/run/media/…`, `/mnt/…`, `/volumes/…`) in one place.
- **Table UI** — Rich display showing filename, drive/volume label, deletion time, and original path.
- **Restore** — Instantly send files back to their original locations with a single keypress.
- **Delete** — Permanently delete items with a safety confirmation.
- **Deep Clean** — Empty your entire trash system across every connected drive.
## Requirements
- [`trash-cli`](https://github.com/andreafrancia/trash-cli) — `sudo apt/dnf/pacman install trash-cli`
## Installation
**`ya pkg`:**
```sh
ya pkg add goon/omni-trash
```
**Manual:**
```sh
git clone https://github.com/goon/omni-trash.yazi \
~/.config/yazi/plugins/omni-trash.yazi
```
## Setup
Add a keybinding to your `~/.config/yazi/keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = "R"
run = "plugin omni-trash"
desc = "Open Omni Trash"
```
## Keybindings
| Key | Action |
|-----|--------|
| `j` / `↓` | Move cursor down |
| `k` / `↑` | Move cursor up |
| `r` | **Restore** selected item |
| `d` | **Purge** (Permanently delete) |
| `E` | **Empty** all trash (Across all drives) |
| `q` / `Esc` | Close Modal |
@@ -0,0 +1,221 @@
--- @since 25.12.29
local toggle_ui = ya.sync(function(st)
if st.children then
Modal:children_remove(st.children)
st.children = nil
else
st.children = Modal:children_add(st, 10)
end
ui.render()
end)
local update_items = ya.sync(function(st, items)
st.items = items
st.cursor = math.max(0, math.min(st.cursor or 0, #st.items - 1))
ui.render()
end)
local update_cursor = ya.sync(function(st, step)
if not st.items or #st.items == 0 then
st.cursor = 0
else
st.cursor = ya.clamp(0, st.cursor + step, #st.items - 1)
end
ui.render()
end)
local get_active_item = ya.sync(function(st)
return st.items and st.items[(st.cursor or 0) + 1]
end)
local M = {
keys = {
{ on = "q", run = "quit" },
{ on = "<Esc>", run = "quit" },
{ on = "k", run = "up" },
{ on = "<Up>", run = "up" },
{ on = "j", run = "down" },
{ on = "<Down>", run = "down" },
{ on = "r", run = "restore" },
{ on = "d", run = "purge" },
{ on = "E", run = "empty" },
},
}
function M:new(area)
self:layout(area)
return self
end
function M:layout(area)
local chunks = ui.Layout()
:direction(ui.Layout.VERTICAL)
:constraints({
ui.Constraint.Percentage(12),
ui.Constraint.Percentage(76),
ui.Constraint.Percentage(12),
})
:split(area)
local hchunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Percentage(5),
ui.Constraint.Percentage(90),
ui.Constraint.Percentage(5),
})
:split(chunks[2])
self._area = hchunks[2]
end
function M:redraw()
if not self._area then return {} end
local count = #(self.items or {})
local title = " r Restore d Delete E Empty q Quit "
local rows = {}
for i, item in ipairs(self.items or {}) do
rows[i] = ui.Row {
item.name,
item.drive,
item.date .. " " .. item.time,
item.path,
}
end
return {
ui.Clear(self._area),
ui.Border(ui.Edge.ALL)
:area(self._area)
:type(ui.Border.ROUNDED)
:style(ui.Style():fg("blue"))
:title(ui.Line(title):align(ui.Align.CENTER)),
ui.Table(rows)
:area(self._area:pad(ui.Pad(1, 2, 1, 2)))
:header(ui.Row({ "Name (" .. count .. ")", "Drive", "Deleted At", "Original Path" }):style(ui.Style():bold()))
:row(self.cursor)
:row_style(ui.Style():fg("cyan"):underline())
:widths {
ui.Constraint.Percentage(20),
ui.Constraint.Percentage(15),
ui.Constraint.Percentage(20),
ui.Constraint.Percentage(45),
},
}
end
function M:reflow() return { self } end
function M:click() end
function M:scroll() end
function M:touch() end
function M.obtain()
local is_macos = ya.target_os() == "macos"
local output, err = Command("trash-list"):output()
if err or not output or not output.status.success then return {} end
local items = {}
for line in output.stdout:gmatch("[^\r\n]+") do
local date, time, path = line:match("^(%d%d%d%d%-%d%d%-%d%d) (%d%d:%d%d:%d%d) (.+)$")
if date and path then
local drive = "Home"
local m = path:match("^/run/media/[^/]+/([^/]+)")
or path:match("^/mnt/([^/]+)")
or path:match("^/Volumes/([^/]+)") -- macOS support
if m then drive = m end
local name = path:match("([^/]+)$") or path
table.insert(items, { name = name, drive = drive, path = path, date = date, time = time })
end
end
table.sort(items, function(a, b) return (a.date .. a.time) > (b.date .. b.time) end)
return items
end
function M:entry(job)
local output, err = Command("trash-list"):arg("--version"):output()
if not output or not output.status.success then
return ya.notify {
title = "Omni Trash",
content = "trash-cli not found. Please install it to use this plugin.",
timeout = 5,
level = "error",
}
end
toggle_ui()
update_items(self.obtain())
while true do
local key_idx = ya.which { cands = self.keys, silent = true }
if not key_idx then break end
local run = self.keys[key_idx].run
if run == "quit" then
break
elseif run == "up" then
update_cursor(-1)
elseif run == "down" then
update_cursor(1)
elseif run == "restore" then
local item = get_active_item()
if item then
local out, err = Command("sh")
:arg({ "-c", 'echo "0" | trash-restore "$1"', "--", item.path })
:output()
if out and out.status.success then
ya.notify { title = "Omni Trash", content = "Restored: " .. item.name, timeout = 3 }
update_items(self.obtain())
else
ya.notify { title = "Omni Trash", content = "Restore failed: " .. (err or "unknown"), timeout = 5, level = "error" }
end
end
elseif run == "purge" then
local item = get_active_item()
if item then
local ok = ya.which {
title = "Purge '" .. item.name .. "' [" .. item.drive .. "]? (cannot be undone)",
cands = {
{ on = "y", desc = "Yes, delete permanently" },
{ on = "n", desc = "No, cancel" },
},
}
if ok == 1 then
local out, err = Command("trash-rm"):arg(item.path):output()
if out and out.status.success then
ya.notify { title = "Omni Trash", content = "Purged: " .. item.name, timeout = 3 }
update_items(self.obtain())
else
ya.notify { title = "Omni Trash", content = "Purge failed: " .. (err or "unknown"), timeout = 5, level = "error" }
end
end
end
elseif run == "empty" then
local ok = ya.which {
title = "Empty ALL trash across all drives? (cannot be undone)",
cands = {
{ on = "y", desc = "Yes, delete everything" },
{ on = "n", desc = "No, cancel" },
},
}
if ok == 1 then
local out, err = Command("sh")
:arg({ "-c", 'echo "y" | trash-empty' })
:output()
if out and out.status.success then
ya.notify { title = "Omni Trash", content = "All trash cleared.", timeout = 3 }
update_items(self.obtain())
else
ya.notify { title = "Omni Trash", content = "Empty failed: " .. (err or "unknown"), timeout = 5, level = "error" }
end
end
end
end
toggle_ui()
end
return M
Submodule yazi/.config/yazi/plugins/omp.yazi added at 32ae96c8da.
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 MasouShizuka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,214 @@
# projects.yazi
A [Yazi](https://github.com/sxyazi/yazi) plugin that adds the functionality to save, load and merge projects.
A project means all `tabs` and their status, including `cwd` and so on.
> [!NOTE]
> The latest release of Yazi is required at the moment.
https://github.com/MasouShizuka/projects.yazi/assets/44764707/79c3559a-7776-48cd-8317-dd1478314eed
## Features
- Save/load projects
- Load last project
- Projects persistence
- Merge a project or its current tab to other projects
## Installation
```sh
ya pkg add MasouShizuka/projects
```
or
```sh
# Windows
git clone https://github.com/MasouShizuka/projects.yazi.git %AppData%\yazi\config\plugins\projects.yazi
# Linux/macOS
git clone https://github.com/MasouShizuka/projects.yazi.git ~/.config/yazi/plugins/projects.yazi
```
## Keymap
Add this to your `keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = [ "P", "s" ]
run = "plugin projects save"
desc = "Save current project"
[[mgr.prepend_keymap]]
on = [ "P", "l" ]
run = "plugin projects load"
desc = "Load project"
[[mgr.prepend_keymap]]
on = [ "P", "P" ]
run = "plugin projects load_last"
desc = "Load last project"
[[mgr.prepend_keymap]]
on = [ "P", "d" ]
run = "plugin projects delete"
desc = "Delete project"
[[mgr.prepend_keymap]]
on = [ "P", "D" ]
run = "plugin projects delete_all"
desc = "Delete all projects"
[[mgr.prepend_keymap]]
on = [ "P", "m" ]
run = "plugin projects 'merge current'"
desc = "Merge current tab to other projects"
[[mgr.prepend_keymap]]
on = [ "P", "M" ]
run = "plugin projects 'merge all'"
desc = "Merge current project to other projects"
```
### Load project by name or key
If you want to load a specific project with a keybinding (you can use either the key or the name of the project):
```toml
[[mgr.prepend_keymap]]
on = [ "P", "p" ]
run = "plugin projects 'load SomeProject'"
desc = "Load the 'SomeProject' project"
```
You can also load a specific project by using the below Bash/Zsh function (uses the "official" [shell wrapper](https://yazi-rs.github.io/docs/quick-start/#shell-wrapper), but you can also replace `y` with `yazi`):
```bash
function yap() {
local yaziProject="$1"
shift
if [ -z "$yaziProject" ]; then
>&2 echo "ERROR: The first argument must be a project"
return 64
fi
# Generate random Yazi client ID (DDS / `ya emit` uses `YAZI_ID`)
local yaziId=$RANDOM
# Use Yazi's DDS to run a plugin command after Yazi has started
# (the nested subshell is only to suppress "Done" output for the job)
( (sleep 0.1; YAZI_ID=$yaziId ya emit plugin projects "load $yaziProject") &)
# Run Yazi with the generated client ID
y --client-id $yaziId "$@" || return $?
}
```
With the above function you can open a specific project by running e.g. `yap SomeProject`
## Config
Don't forget to add the plugin's `setup` function in Yazi's `init.lua`, i.e. `~/.config/yazi/init.lua`.
The following are the default configurations:
```lua
require("projects"):setup({
event = {
save = {
enable = true,
name = "project-saved",
},
load = {
enable = true,
name = "project-loaded",
},
delete = {
enable = true,
name = "project-deleted",
},
delete_all = {
enable = true,
name = "project-deleted-all",
},
merge = {
enable = true,
name = "project-merged",
},
},
save = {
method = "yazi", -- yazi | lua
yazi_load_event = "@projects-load", -- event name when loading projects in `yazi` method
lua_save_path = "", -- path of saved file in `lua` method, comment out or assign explicitly
-- default value:
-- windows: "%APPDATA%/yazi/state/projects.json"
-- unix: "~/.local/state/yazi/projects.json"
},
last = {
update_after_save = true,
update_after_load = true,
update_before_quit = false,
load_after_start = false,
},
merge = {
event = "projects-merge",
quit_after_merge = false,
},
notify = {
enable = true,
title = "Projects",
timeout = 3,
level = "info",
},
})
```
> [!NOTE]
> Settings that are not set will use the default value.
### `event`
The corresponding event will be sent when the corresponding function is executed.
For specific usage, please refer to [#5](https://github.com/MasouShizuka/projects.yazi/issues/5) and [#12](https://github.com/MasouShizuka/projects.yazi/issues/12).
### `save`
> [!NOTE]
> Yazi's api sometimes doesn't work on Windows, which is why the `lua` method is proposed
`method`: the method of saving projects:
- `yazi`: using `yazi` api to save to `.dds` file
- `lua`: using `lua` api to save
`yazi_load_event`: event name when loading projects in `yazi` method
`lua_save_path`: path of saved file in `lua` method, the defalut value is
- `Windows`: `%APPDATA%/yazi/state/projects.json`
- `Unix`: `~/.local/state/yazi/projects.json`
### `last`
The last project is loaded by `load_last` command.
`update_after_save`: the saved project will be saved to last project.
`update_after_load`: the loaded project will be saved to last project.
`update_before_quit`: the current project will be saved to last project before quit.
`load_after_start`: the last project will be loaded after starting.
- Only work with `lua` method, please refer to [#2](https://github.com/MasouShizuka/projects.yazi/issues/2)
### `merge`
`event`: the name of event used by merge feature.
`quit_after_merge`: the merged project will be exited after merging.
### `notify`
When enabled, notifications are displayed when actions are performed.
`title`, `timeout`, `level` are the same as [ya.notify](https://yazi-rs.github.io/docs/plugins/utils/#ya.notify).
@@ -0,0 +1,386 @@
--
-- json.lua
--
-- Copyright (c) 2020 rxi
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy of
-- this software and associated documentation files (the "Software"), to deal in
-- the Software without restriction, including without limitation the rights to
-- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
-- of the Software, and to permit persons to whom the Software is furnished to do
-- so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--
local json = { _version = "0.1.2" }
-------------------------------------------------------------------------------
-- Encode
-------------------------------------------------------------------------------
local encode
local escape_char_map = {
["\\"] = "\\",
["\""] = "\"",
["\b"] = "b",
["\f"] = "f",
["\n"] = "n",
["\r"] = "r",
["\t"] = "t",
}
local escape_char_map_inv = { ["/"] = "/" }
for k, v in pairs(escape_char_map) do
escape_char_map_inv[v] = k
end
local function escape_char(c)
return "\\" .. (escape_char_map[c] or string.format("u%04x", c:byte()))
end
local function encode_nil(val)
return "null"
end
local function encode_table(val, stack)
local res = {}
stack = stack or {}
-- Circular reference?
if stack[val] then error("circular reference") end
stack[val] = true
if rawget(val, 1) ~= nil or next(val) == nil then
-- Treat as array -- check keys are valid and it is not sparse
local n = 0
for k in pairs(val) do
if type(k) ~= "number" then
error("invalid table: mixed or invalid key types")
end
n = n + 1
end
if n ~= #val then
error("invalid table: sparse array")
end
-- Encode
for i, v in ipairs(val) do
table.insert(res, encode(v, stack))
end
stack[val] = nil
return "[" .. table.concat(res, ",") .. "]"
else
-- Treat as an object
for k, v in pairs(val) do
if type(k) ~= "string" then
error("invalid table: mixed or invalid key types")
end
table.insert(res, encode(k, stack) .. ":" .. encode(v, stack))
end
stack[val] = nil
return "{" .. table.concat(res, ",") .. "}"
end
end
local function encode_string(val)
return '"' .. val:gsub('[%z\1-\31\\"]', escape_char) .. '"'
end
local function encode_number(val)
-- Check for NaN, -inf and inf
if val ~= val or val <= -math.huge or val >= math.huge then
error("unexpected number value '" .. tostring(val) .. "'")
end
return string.format("%.14g", val)
end
local type_func_map = {
["nil"] = encode_nil,
["table"] = encode_table,
["string"] = encode_string,
["number"] = encode_number,
["boolean"] = tostring,
}
encode = function(val, stack)
local t = type(val)
local f = type_func_map[t]
if f then
return f(val, stack)
end
error("unexpected type '" .. t .. "'")
end
function json.encode(val)
return (encode(val))
end
-------------------------------------------------------------------------------
-- Decode
-------------------------------------------------------------------------------
local parse
local function create_set(...)
local res = {}
for i = 1, select("#", ...) do
res[select(i, ...)] = true
end
return res
end
local space_chars = create_set(" ", "\t", "\r", "\n")
local delim_chars = create_set(" ", "\t", "\r", "\n", "]", "}", ",")
local escape_chars = create_set("\\", "/", '"', "b", "f", "n", "r", "t", "u")
local literals = create_set("true", "false", "null")
local literal_map = {
["true"] = true,
["false"] = false,
["null"] = nil,
}
local function next_char(str, idx, set, negate)
for i = idx, #str do
if set[str:sub(i, i)] ~= negate then
return i
end
end
return #str + 1
end
local function decode_error(str, idx, msg)
local line_count = 1
local col_count = 1
for i = 1, idx - 1 do
col_count = col_count + 1
if str:sub(i, i) == "\n" then
line_count = line_count + 1
col_count = 1
end
end
error(string.format("%s at line %d col %d", msg, line_count, col_count))
end
local function codepoint_to_utf8(n)
-- http://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=iws-appendixa
local f = math.floor
if n <= 0x7f then
return string.char(n)
elseif n <= 0x7ff then
return string.char(f(n / 64) + 192, n % 64 + 128)
elseif n <= 0xffff then
return string.char(f(n / 4096) + 224, f(n % 4096 / 64) + 128, n % 64 + 128)
elseif n <= 0x10ffff then
return string.char(f(n / 262144) + 240, f(n % 262144 / 4096) + 128,
f(n % 4096 / 64) + 128, n % 64 + 128)
end
error(string.format("invalid unicode codepoint '%x'", n))
end
local function parse_unicode_escape(s)
local n1 = tonumber(s:sub(1, 4), 16)
local n2 = tonumber(s:sub(7, 10), 16)
-- Surrogate pair?
if n2 then
return codepoint_to_utf8((n1 - 0xd800) * 0x400 + (n2 - 0xdc00) + 0x10000)
else
return codepoint_to_utf8(n1)
end
end
local function parse_string(str, i)
local res = ""
local j = i + 1
local k = j
while j <= #str do
local x = str:byte(j)
if x < 32 then
decode_error(str, j, "control character in string")
elseif x == 92 then -- `\`: Escape
res = res .. str:sub(k, j - 1)
j = j + 1
local c = str:sub(j, j)
if c == "u" then
local hex = str:match("^[dD][89aAbB]%x%x\\u%x%x%x%x", j + 1)
or str:match("^%x%x%x%x", j + 1)
or decode_error(str, j - 1, "invalid unicode escape in string")
res = res .. parse_unicode_escape(hex)
j = j + #hex
else
if not escape_chars[c] then
decode_error(str, j - 1, "invalid escape char '" .. c .. "' in string")
end
res = res .. escape_char_map_inv[c]
end
k = j + 1
elseif x == 34 then -- `"`: End of string
res = res .. str:sub(k, j - 1)
return res, j + 1
end
j = j + 1
end
decode_error(str, i, "expected closing quote for string")
end
local function parse_number(str, i)
local x = next_char(str, i, delim_chars)
local s = str:sub(i, x - 1)
local n = tonumber(s)
if not n then
decode_error(str, i, "invalid number '" .. s .. "'")
end
return n, x
end
local function parse_literal(str, i)
local x = next_char(str, i, delim_chars)
local word = str:sub(i, x - 1)
if not literals[word] then
decode_error(str, i, "invalid literal '" .. word .. "'")
end
return literal_map[word], x
end
local function parse_array(str, i)
local res = {}
local n = 1
i = i + 1
while 1 do
local x
i = next_char(str, i, space_chars, true)
-- Empty / end of array?
if str:sub(i, i) == "]" then
i = i + 1
break
end
-- Read token
x, i = parse(str, i)
res[n] = x
n = n + 1
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "]" then break end
if chr ~= "," then decode_error(str, i, "expected ']' or ','") end
end
return res, i
end
local function parse_object(str, i)
local res = {}
i = i + 1
while 1 do
local key, val
i = next_char(str, i, space_chars, true)
-- Empty / end of object?
if str:sub(i, i) == "}" then
i = i + 1
break
end
-- Read key
if str:sub(i, i) ~= '"' then
decode_error(str, i, "expected string for key")
end
key, i = parse(str, i)
-- Read ':' delimiter
i = next_char(str, i, space_chars, true)
if str:sub(i, i) ~= ":" then
decode_error(str, i, "expected ':' after key")
end
i = next_char(str, i + 1, space_chars, true)
-- Read value
val, i = parse(str, i)
-- Set
res[key] = val
-- Next token
i = next_char(str, i, space_chars, true)
local chr = str:sub(i, i)
i = i + 1
if chr == "}" then break end
if chr ~= "," then decode_error(str, i, "expected '}' or ','") end
end
return res, i
end
local char_func_map = {
['"'] = parse_string,
["0"] = parse_number,
["1"] = parse_number,
["2"] = parse_number,
["3"] = parse_number,
["4"] = parse_number,
["5"] = parse_number,
["6"] = parse_number,
["7"] = parse_number,
["8"] = parse_number,
["9"] = parse_number,
["-"] = parse_number,
["t"] = parse_literal,
["f"] = parse_literal,
["n"] = parse_literal,
["["] = parse_array,
["{"] = parse_object,
}
parse = function(str, idx)
local chr = str:sub(idx, idx)
local f = char_func_map[chr]
if f then
return f(str, idx)
end
decode_error(str, idx, "unexpected character '" .. chr .. "'")
end
function json.decode(str)
if type(str) ~= "string" then
error("expected argument of type string, got " .. type(str))
end
local res, idx = parse(str, next_char(str, 1, space_chars, true))
idx = next_char(str, idx, space_chars, true)
if idx <= #str then
decode_error(str, idx, "trailing garbage")
end
return res
end
return {
encode = json.encode,
decode = json.decode,
}
@@ -0,0 +1,666 @@
local SUPPORTED_KEYS_MAP = {
["0"] = 1,
["1"] = 2,
["2"] = 3,
["3"] = 4,
["4"] = 5,
["5"] = 6,
["6"] = 7,
["7"] = 8,
["8"] = 9,
["9"] = 10,
["A"] = 11,
["B"] = 12,
["C"] = 13,
["D"] = 14,
["E"] = 15,
["F"] = 16,
["G"] = 17,
["H"] = 18,
["I"] = 19,
["J"] = 20,
["K"] = 21,
["L"] = 22,
["M"] = 23,
["N"] = 24,
["O"] = 25,
["P"] = 26,
["Q"] = 27,
["R"] = 28,
["S"] = 29,
["T"] = 30,
["U"] = 31,
["V"] = 32,
["W"] = 33,
["X"] = 34,
["Y"] = 35,
["Z"] = 36,
["a"] = 37,
["b"] = 38,
["c"] = 39,
["d"] = 40,
["e"] = 41,
["f"] = 42,
["g"] = 43,
["h"] = 44,
["i"] = 45,
["j"] = 46,
["k"] = 47,
["l"] = 48,
["m"] = 49,
["n"] = 50,
["o"] = 51,
["p"] = 52,
["q"] = 53,
["r"] = 54,
["s"] = 55,
["t"] = 56,
["u"] = 57,
["v"] = 58,
["w"] = 59,
["x"] = 60,
["y"] = 61,
["z"] = 62,
}
local SUPPORTED_KEYS = {
{ on = "0" },
{ on = "1" },
{ on = "2" },
{ on = "3" },
{ on = "4" },
{ on = "5" },
{ on = "6" },
{ on = "7" },
{ on = "8" },
{ on = "9" },
{ on = "A" },
{ on = "B" },
{ on = "C" },
{ on = "D" },
{ on = "E" },
{ on = "F" },
{ on = "G" },
{ on = "H" },
{ on = "I" },
{ on = "J" },
{ on = "K" },
{ on = "L" },
{ on = "M" },
{ on = "N" },
{ on = "O" },
{ on = "P" },
{ on = "Q" },
{ on = "R" },
{ on = "S" },
{ on = "T" },
{ on = "U" },
{ on = "V" },
{ on = "W" },
{ on = "X" },
{ on = "Y" },
{ on = "Z" },
{ on = "a" },
{ on = "b" },
{ on = "c" },
{ on = "d" },
{ on = "e" },
{ on = "f" },
{ on = "g" },
{ on = "h" },
{ on = "i" },
{ on = "j" },
{ on = "k" },
{ on = "l" },
{ on = "m" },
{ on = "n" },
{ on = "o" },
{ on = "p" },
{ on = "q" },
{ on = "r" },
{ on = "s" },
{ on = "t" },
{ on = "u" },
{ on = "v" },
{ on = "w" },
{ on = "x" },
{ on = "y" },
{ on = "z" },
}
local _notify = ya.sync(function(state, message)
ya.notify({
title = state.notify.title,
content = message,
timeout = state.notify.timeout,
level = state.notify.level,
})
end)
local _get_default_projects = ya.sync(function(state)
return {
list = {},
last = nil,
}
end)
local _get_projects = ya.sync(function(state)
return not state.projects and _get_default_projects() or state.projects
end)
local _get_real_idx = ya.sync(function(state, idx)
for real_idx, value in ipairs(_get_projects().list) do
if value.on == SUPPORTED_KEYS[idx].on then
return real_idx
end
end
return nil
end)
local _get_current_project = ya.sync(function(state)
local tabs = cx.tabs
-- TODO: add more tab properties
local project = {
active_idx = tonumber(tabs.idx),
tabs = {},
}
for index, tab in ipairs(tabs) do
-- store user-set custom name ('tab.pref.name') if non-empty;
-- don't use 'tab.name', which falls back to the directory name
local name = ""
if tab.pref and tab.pref.name and tab.pref.name ~= "" then
name = tab.pref.name
end
project.tabs[#project.tabs + 1] = {
idx = index,
cwd = tostring(tab.current.cwd):gsub("\\", "/"),
name = name,
}
end
return project
end)
local _restore_tab = ya.sync(function(state, tab)
ya.emit("tab_create", { tab.cwd })
-- if available, rename freshly-created (focused) tab with custom name
if tab.name then
ya.emit("tab_rename", { tab.name })
end
end)
local _save_projects = ya.sync(function(state, projects)
state.projects = projects
if state.save.method == "yazi" then
pcall(ps.pub_to, 0, state.save.yazi_load_event, projects)
elseif state.save.method == "lua" then
local f = io.open(state.save.lua_save_path, "w")
if not f then
return
end
f:write(state.json.encode(projects))
io.close(f)
end
end)
local save_project = ya.sync(function(state, idx, desc)
local projects = _get_projects()
local real_idx = _get_real_idx(idx)
if not real_idx then
real_idx = #projects.list + 1
end
local project = _get_current_project()
projects.list[real_idx] = {
on = SUPPORTED_KEYS[idx].on,
desc = desc,
project = project,
}
if state.last.update_after_save then
projects.last = project
end
_save_projects(projects)
if state.event.save.enable then
pcall(ps.pub_to, 0, state.event.save.name, project)
end
if state.notify.enable then
local message = string.format("Project saved to %s", state.projects.list[real_idx].on)
_notify(message)
end
end)
local load_project = ya.sync(function(state, project, desc)
-- TODO: add more tab properties to restore
-- when cx is nil, it is called in setup
if cx then
for _ = 1, #cx.tabs - 1 do
ya.emit("tab_close", { 0 })
end
end
local sorted_tabs = {}
for _, tab in pairs(project.tabs) do
sorted_tabs[tonumber(tab.idx)] = tab
end
for index, tab in ipairs(sorted_tabs) do
_restore_tab(tab)
if index == 1 then
ya.emit("tab_close", { 0 })
end
end
ya.emit("tab_switch", { project.active_idx - 1 })
if state.last.update_after_load then
local projects = _get_projects()
projects.last = project
_save_projects(projects)
end
if state.event.load.enable then
pcall(ps.pub_to, 0, state.event.load.name, project)
end
if state.notify.enable then
local message
if desc then
message = string.format([["%s" loaded]], desc)
else
message = string.format([[Last project loaded]], desc)
end
_notify(message)
end
end)
local _load_projects = ya.sync(function(state)
if state.save.method == "yazi" then
ps.sub_remote(state.save.yazi_load_event, function(body)
state.projects = body
end)
elseif state.save.method == "lua" then
local f = io.open(state.save.lua_save_path, "r")
if f then
state.projects = state.json.decode(f:read("*a"))
io.close(f)
end
end
if not state.projects then
state.projects = _get_default_projects()
end
if state.last.load_after_start then
local last_project = _get_projects().last
if last_project then
load_project(last_project)
end
end
end)
local delete_all_projects = ya.sync(function(state)
_save_projects(_get_default_projects())
local msg = "All projects deleted"
if state.event.delete_all.enable then
ps.pub_to(0, state.event.delete_all.name, msg)
end
if state.notify.enable then
_notify(msg)
end
end)
local delete_project = ya.sync(function(state, idx)
local projects = _get_projects()
local message = string.format([["%s" deleted]], tostring(projects.list[idx].desc))
local deleted_project = projects.list[idx]
table.remove(projects.list, idx)
_save_projects(projects)
if state.event.delete.enable then
pcall(ps.pub_to, 0, state.event.delete.name, deleted_project)
end
if state.notify.enable then
_notify(message)
end
end)
local merge_project = ya.sync(function(state, opt)
local project = _get_current_project()
project.opt = opt or "all"
pcall(ps.pub_to, 0, state.merge.event, project)
if state.event.merge.enable then
pcall(ps.pub_to, 0, state.event.merge.name, project)
end
if state.merge.quit_after_merge then
ya.emit("quit", {})
end
end)
local _merge_event = ya.sync(function(state)
ps.sub_remote(state.merge.event, function(body)
if body then
local active_idx = tonumber(cx.tabs.idx)
local opt = body.opt
if opt == "all" then
local sorted_tabs = {}
for _, tab in pairs(body.tabs) do
sorted_tabs[tonumber(tab.idx)] = tab
end
for _, tab in ipairs(sorted_tabs) do
_restore_tab(tab)
end
if state.notify.enable then
local message = "A project is merged"
_notify(message)
end
elseif opt == "current" then
local tab = body.tabs[tonumber(body.active_idx)]
_restore_tab(tab)
if state.notify.enable then
local message = "A tab is merged"
_notify(message)
end
end
ya.emit("tab_switch", { active_idx - 1 })
end
end)
end)
local _find_project_index = ya.sync(function(state, list, search_term)
if not search_term then
return nil
end
for i, project in ipairs(list) do
-- Match the project by the "on" key or by "desc"
if project.on == search_term or project.desc == search_term then
return i
end
end
return nil
end)
local _load_config = ya.sync(function(state, opts)
state.event = {
save = {
enable = true,
name = "project-saved",
},
load = {
enable = true,
name = "project-loaded",
},
delete = {
enable = true,
name = "project-deleted",
},
delete_all = {
enable = true,
name = "project-deleted-all",
},
merge = {
enable = true,
name = "project-merged",
},
}
if type(opts.event) == "table" then
if type(opts.event.save) == "table" then
if type(opts.event.save.enable) == "boolean" then
state.event.save.enable = opts.event.save.enable
end
if type(opts.event.save.name) == "string" then
state.event.save.name = opts.event.save.name
end
elseif type(opts.event.save) == "boolean" then
state.event.save.enable = opts.event.save
end
if type(opts.event.load) == "table" then
if type(opts.event.load.enable) == "boolean" then
state.event.load.enable = opts.event.load.enable
end
if type(opts.event.load.name) == "string" then
state.event.load.name = opts.event.load.name
end
elseif type(opts.event.load) == "boolean" then
state.event.load.enable = opts.event.load
end
if type(opts.event.delete) == "table" then
if type(opts.event.delete.enable) == "boolean" then
state.event.delete.enable = opts.event.delete.enable
end
if type(opts.event.delete.name) == "string" then
state.event.delete.name = opts.event.delete.name
end
elseif type(opts.event.delete) == "boolean" then
state.event.delete.enable = opts.event.delete
end
if type(opts.event.delete_all) == "table" then
if type(opts.event.delete_all.enable) == "boolean" then
state.event.delete_all.enable = opts.event.delete_all.enable
end
if type(opts.event.delete_all.name) == "string" then
state.event.delete_all.name = opts.event.delete_all.name
end
elseif type(opts.event.delete_all) == "boolean" then
state.event.delete_all.enable = opts.event.delete_all
end
if type(opts.event.merge) == "table" then
if type(opts.event.merge.enable) == "boolean" then
state.event.merge.enable = opts.event.merge.enable
end
if type(opts.event.merge.name) == "string" then
state.event.merge.name = opts.event.merge.name
end
elseif type(opts.event.merge) == "boolean" then
state.event.merge.enable = opts.event.merge
end
end
state.save = {
method = "yazi",
yazi_load_event = "@projects-load",
lua_save_path = "",
}
if type(opts.save) == "table" then
if type(opts.save.method) == "string" then
state.save.method = opts.save.method
end
if type(opts.save.yazi_load_event) == "string" then
state.save.yazi_load_event = opts.save.yazi_load_event
end
if type(opts.save.lua_save_path) == "string" then
state.save.lua_save_path = opts.save.lua_save_path
else
local lua_save_path
local appdata = os.getenv("APPDATA")
if appdata then
lua_save_path = appdata:gsub("\\", "/") .. "/yazi/state/projects.json"
else
lua_save_path = os.getenv("HOME") .. "/.local/state/yazi/projects.json"
end
state.save.lua_save_path = lua_save_path
end
end
state.last = {
update_after_save = true,
update_after_load = true,
update_before_quit = false,
load_after_start = false,
}
if type(opts.last) == "table" then
if type(opts.last.update_after_save) == "boolean" then
state.last.update_after_save = opts.last.update_after_save
end
if type(opts.last.update_after_load) == "boolean" then
state.last.update_after_load = opts.last.update_after_load
end
if type(opts.last.update_before_quit) == "boolean" then
state.last.update_before_quit = opts.last.update_before_quit
end
if type(opts.last.load_after_start) == "boolean" then
state.last.load_after_start = opts.last.load_after_start
end
end
if state.last.update_before_quit then
ps.sub("key-quit", function(body)
local projects = _get_projects()
local current_project = _get_current_project()
projects.last = current_project
_save_projects(projects)
if state.event.save.enable then
pcall(ps.pub_to, 0, state.event.save.name, current_project)
end
ya.emit("quit", {})
return true
end)
end
state.merge = {
event = "projects-merge",
quit_after_merge = false,
}
if type(opts.merge) == "table" then
if type(opts.merge.event) == "string" then
state.merge.event = opts.merge.event
end
if type(opts.merge.quit_after_merge) == "boolean" then
state.merge.quit_after_merge = opts.merge.quit_after_merge
end
end
state.notify = {
enable = true,
title = "Projects",
timeout = 3,
level = "info",
}
if type(opts.notify) == "table" then
if type(opts.notify.enable) == "boolean" then
state.notify.enable = opts.notify.enable
end
if type(opts.notify.title) == "string" then
state.notify.title = opts.notify.title
end
if type(opts.notify.timeout) == "number" then
state.notify.timeout = opts.notify.timeout
end
if type(opts.notify.level) == "string" then
state.notify.level = opts.notify.level
end
end
end)
return {
setup = function(state, opts)
state.json = require(".json")
_load_config(opts)
_load_projects()
_merge_event()
end,
entry = function(_, job)
local action = job.args[1]
if not action then
return
end
if action == "delete_all" then
delete_all_projects()
return
end
if action == "merge" then
local opt = job.args[2]
merge_project(opt)
return
end
local projects = _get_projects()
if action == "load_last" then
local last_project = projects.last
if last_project then
load_project(last_project)
end
return
end
local list = projects.list
if action == "save" then
-- load the desc of saved projects
for _, value in pairs(list) do
local idx = SUPPORTED_KEYS_MAP[value.on]
if idx then
SUPPORTED_KEYS[idx].desc = value.desc
end
end
local idx = ya.which({ cands = SUPPORTED_KEYS, silent = false })
if not idx then
return
end
-- if target is not empty, use the saved desc as default desc
local default_desc = SUPPORTED_KEYS[idx].desc or string.format("Project %s", SUPPORTED_KEYS[idx].on)
local value, event = ya.input({
pos = { "center", w = 40 },
title = "Project name:",
value = default_desc,
})
if event ~= 1 then
return
end
local desc
if value ~= "" then
desc = value
else
desc = default_desc
end
save_project(idx, desc)
return
end
-- Search for the project, if an argument was given
-- Or ask interactively
local selected_idx = _find_project_index(list, job.args[2]) or ya.which({ cands = list, silent = false })
if not selected_idx then
return
end
if action == "load" then
local selected = list[selected_idx]
load_project(selected.project, selected.desc)
elseif action == "delete" then
delete_project(selected_idx)
end
end,
}
@@ -0,0 +1,5 @@
home /home/liph f
Downloads /home/liph/Downloads D,d
dotfiles /home/liph/dotfiles d,d
Documents /home/liph/Documents D,D
.config /home/liph/.config c
+661
View File
@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
@@ -0,0 +1,79 @@
# yafg.yazi (Yet Another FG)
Fuzzy find and grep in Yazi using ripgrep and fzf. This plugin provides an interactive search interface that allows you to search file contents and open results directly in your configured editor.
> Inspired by [fg.yazi](https://github.com/DreamMaoMao/fg.yazi)
## Requirements
- `bash`
- `rg` (ripgrep)
- `fzf`
- `bat`
- A text editor (default: `hx` Helix)
## Installation
Install the plugin via the package manager:
```bash
ya pkg add XYenon/yafg
```
This clones the repository, adds it to `~/.config/yazi/package.toml`, and pins the current revision.
## Usage
Add a shortcut in `~/.config/yazi/keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = [ "F", "G" ]
run = "plugin yafg"
```
## Configuration
Customize the editor and command format in `~/.config/yazi/init.lua`:
```lua
require("yafg"):setup({
toggle_mode_key = "alt-t", -- fzf key to switch ripgrep/fzf mode (default: "ctrl-t")
editor = "nvim", -- Editor command (default: "hx")
args = { "--noplugin" }, -- Additional editor arguments (default: {})
file_arg_format = "+{row} {file}", -- File argument format (default: "{file}:{row}:{col}")
})
```
`toggle_mode_key` uses the key syntax supported by `fzf --bind`, for example `ctrl-y`, `alt-t`, or `f1`.
Format placeholders:
- `{file}` - File path
- `{row}` - Line number
- `{col}` - Column number
## Features
- **Interactive search**: Use ripgrep to search file contents with live preview
- **Switch modes**: Press the configured toggle key (default: `Ctrl-T`) to switch between ripgrep and fzf modes
- **Multi-select**: Select multiple search results
- **Preview**: View file contents with syntax highlighting via bat
- **Direct open**: Opens selected files in your configured editor at the matched line
- **Configurable**: Customize editor command, arguments, and file format
## Troubleshooting
- **Failed to start fzf**: ensure all required dependencies are installed (`rg`, `fzf`, `bat`, `bash`).
- **Preview not working**: install `bat` for syntax-highlighted previews.
- **Editor not opening**: ensure your configured editor is installed and in your PATH, or customize it in `init.lua`.
## Development
This repository uses [treefmt](https://github.com/numtide/treefmt) for formatting:
```bash
nix fmt
```
Feel free to open a PR to add more features or support additional editors.
@@ -0,0 +1,126 @@
local M = {
toggle_mode_key = "ctrl-t",
editor = "hx",
args = {},
file_arg_format = "{file}:{row}:{col}",
}
local cwd = ya.sync(function()
return cx.active.current.cwd
end)
local sync_self = ya.sync(function()
local self = {}
for key, value in pairs(M) do
if type(value) ~= "function" then
self[key] = value
end
end
return self
end)
local function format_key_for_display(key)
return (key:gsub("[^-]+", function(part)
return part:sub(1, 1):upper() .. part:sub(2)
end))
end
function M:setup(opts)
self.toggle_mode_key = opts.toggle_mode_key or self.toggle_mode_key
self.editor = opts.editor or self.editor
self.args = opts.args or self.args
self.file_arg_format = opts.file_arg_format or self.file_arg_format
end
function M:entry()
ya.emit("escape", { visual = true })
local _permit = ui.hide()
local cwd = cwd()
local output, err = M.run_with(cwd)
if not output then
return ya.notify({ title = "Yafg", content = tostring(err), timeout = 5, level = "error" })
end
local results = M.split_results(cwd, output)
if #results == 0 then
return
elseif #results == 1 then
local first_url = results[1][1]
local cha = fs.cha(first_url)
ya.emit(cha and cha.is_dir and "cd" or "reveal", { Url(first_url) })
end
local ss = sync_self()
local args = {}
for i, arg in ipairs(ss.args) do
args[i] = ya.quote(arg)
end
local file_args = {}
for i, result in ipairs(results) do
local arg = string.gsub(ss.file_arg_format, "{file}", ya.quote(tostring(result[1])))
arg = string.gsub(arg, "{row}", tostring(result[2]))
arg = string.gsub(arg, "{col}", tostring(result[3]))
file_args[i] = arg
end
local cmd = ss.editor .. " " .. table.concat(args, " ") .. " " .. table.concat(file_args, " ")
ya.dbg("Yafg", "editor cmd", cmd)
os.execute(cmd)
end
function M.run_with(cwd)
local ss = sync_self()
local cmd_args = "TOGGLE_KEY="
.. ya.quote(ss.toggle_mode_key)
.. " DISPLAY_TOGGLE_KEY="
.. ya.quote(format_key_for_display(ss.toggle_mode_key))
.. [=[
RG_PREFIX='rg --column --line-number --no-heading --color=always --smart-case'
PREVIEW='bat --color=always --highlight-line={2} {1}'
fzf --ansi --disabled --multi \
--bind "start:reload:${RG_PREFIX} {q}" \
--bind "change:reload:sleep 0.1; ${RG_PREFIX} {q} || true" \
--bind "${TOGGLE_KEY}:transform:[[ ! \${FZF_PROMPT} =~ ripgrep ]] &&
echo 'rebind(change)+change-prompt(1. ripgrep> )+disable-search+reload:${RG_PREFIX} \{q} || true' ||
echo 'unbind(change)+change-prompt(2. fzf> )+enable-search+reload:${RG_PREFIX} \"\" || true'" \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--prompt '1. ripgrep> ' \
--delimiter : \
--header "${DISPLAY_TOGGLE_KEY}: Switch between ripgrep/fzf" \
--preview "${PREVIEW}" \
--preview-window 'up,60%,~3,+{2}+3/2' \
--nth '3..'
]=]
local child, err =
Command("bash"):arg({ "-c", cmd_args }):cwd(tostring(cwd)):stdin(Command.INHERIT):stdout(Command.PIPED):spawn()
if not child then
return nil, Err("Failed to start `fzf`, error: %s", err)
end
local output, err = child:wait_with_output()
if not output then
return nil, Err("Cannot read `fzf` output, error: %s", err)
elseif not output.status.success and output.status.code ~= 130 then
return nil, Err("`fzf` exited with error code %s", output.status.code)
end
return output.stdout, nil
end
function M.split_results(cwd, output)
local t = {}
for line in output:gmatch("[^\r\n]+") do
local file, row, col = (string.gmatch(line, "(..-):(%d+):(%d+):"))()
local u = Url(file)
if u.is_absolute then
t[#t + 1] = { u, row, col }
else
t[#t + 1] = { cwd:join(u), row, col }
end
end
return t
end
return M
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 llanosrocas
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,148 @@
# yaziline.yazi
Simple lualine-like status line for yazi.
![angly](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/angly.png)
![preview-fullscreen](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/preview-fullscreen.png)
All supported features are listed [here](#features). More presets are available [here](#presets).
## Requirements
- yazi version >= [26.8.15](https://github.com/sxyazi/yazi/releases/tag/v26.8.15).
- Font with symbol support. For example [Nerd Fonts](https://www.nerdfonts.com/).
## Compatibility
To keep the plugin up to date, there are two branches: `main` and `nightly`.
The `main` branch follows major yazi releases, while `nightly` is linked to specific yazi commits or changes.
This setup allows shipping stable versions on time, while giving early access to "cutting-edge" changes. See matrix below.
<details close>
<summary>Compatibility matrix</summary>
| yaziline | yazi |
| :------------------------------------------------------------------------: | ----------------------------------------------------------------------------------------- |
| [v2.5.6](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.6) | [v26.8.15](https://github.com/sxyazi/yazi/releases/tag/v26.8.15) |
| [v2.5.5](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.5) | [v26.5.6](https://github.com/sxyazi/yazi/releases/tag/v26.5.6) |
| [v2.5.4](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.4) | [v26.5.6](https://github.com/sxyazi/yazi/releases/tag/v26.5.6) |
| [v2.5.3](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.3) | [v26.1.22](https://github.com/sxyazi/yazi/releases/tag/v26.1.22) |
| [v2.5.2](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.2) | [v26.1.22](https://github.com/sxyazi/yazi/releases/tag/v26.1.22) |
| [v2.5.2](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.2) | [2f66561](https://github.com/sxyazi/yazi/commit/2f66561a8251f8788b2b0fd366af90555ecafc86) |
| [v2.5.2](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.2) | [6cfa92f](https://github.com/sxyazi/yazi/commit/6cfa92f11205d212155579b5b76d4cbabe723829) |
| [v2.5.2](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.2) | [917e1f5](https://github.com/sxyazi/yazi/commit/917e1f54a10445f2e25147c4b81a3c77d8233632) |
| [v2.5.1](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.1) | [917e1f5](https://github.com/sxyazi/yazi/commit/917e1f54a10445f2e25147c4b81a3c77d8233632) |
| [v2.5.0](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.0) | [v25.5.28](https://github.com/sxyazi/yazi/releases/tag/v25.5.28) |
| [v2.4.0](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.4.0) | [v25.4.8](https://github.com/sxyazi/yazi/releases/tag/v25.4.8) |
</details>
## Installation
1. Using yazi package manager
```sh
ya pkg add llanosrocas/yaziline
```
_Or manually copy `main.lua` to the `~/.config/yazi/plugins/yaziline.yazi/main.lua`_
2. Add this line to your `~/.config/yazi/init.lua`:
```lua
require("yaziline"):setup()
```
## Configuration
This is default config, if you want to see presets go to [this section](#presets).
```lua
require("yaziline"):setup({
color = "#98c379",
secondary_color = "#5a6078",
default_files_color = "darkgray", -- color of the file counter when it's inactive
selected_files_color = "white",
yanked_files_color = "green",
cut_files_color = "red",
separator_style = "angly", -- "angly" | "curvy" | "liney" | "empty"
separator_open = "",
separator_close = "",
separator_open_thin = "",
separator_close_thin = "",
separator_head = "",
separator_tail = "",
select_symbol = "",
yank_symbol = "󰆐",
filename_max_length = 24, -- truncate when filename > 24
filename_truncate_length = 6, -- leave 6 chars on both sides
filename_truncate_separator = "..."
})
```
By default yaziline uses color values from `theme.toml`:
- mode and position text color (fg): `th.which.mask.bg`
- mode, position, and percent background / primary color: `style.main.bg`
- secondary_color (separators, modified date, empty dir label): `which.separator_style.fg`
- default_files_color: `secondary_color`, falling back to `which.separator_style.fg`, falling back to "darkgray"
- selected_files_color: `mgr.count_selected.bg`
- yanked_files_color: `mgr.count_copied.bg`
- cut_files_color: `mgr.count_cut.bg`
```
 MODE  size  long_file...name.md  S 0 Y 0
| | | | | | | | |
| | | | | | | | └─── yank_symbol
| | | | | | | └─────── select_symbol
| | | | | | └───────── separator_close_thin
| | | | | └─────────────────── filename_truncate_separator
| | | | └─────────────────────────────── separator_close
| | | └────────────────────────────────── secondary_color
| | └────────────────────────────────────── separator_close
| └────────────────────────────────────────── color
└───────────────────────────────────────────── separator_head
```
## Features
### Presets
- `angly`
![angly](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/angly.png)
- `curvy`
![curvy](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/curvy.png)
- `liney`
![liney](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/liney.png)
- `empty`
![empty](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/empty.png)
### Selected and Yanked Counter
Displays the number of selected ('S') and yanked ('Y') files on the left. If files are cut, the yank counter changes color, since its `yank --cut` under the hood.
### Truncated filename
Displays the truncated filename on the left, which is useful for smaller windows or long filenames. By default, it's 24 characters with trimming to 12 (6 + 6). Adjust in the `setup`.
```lua
require("yaziline"):setup({
filename_max_length = 24,
filename_truncate_length = 6,
filename_truncate_separator = "..."
})
```
### ISO Date for 'Modified'
On the right, you'll find the date and time the file was modified, formatted in an [ISO](https://en.wikipedia.org/wiki/ISO_8601)-like string for universal date representation. Adjust in the `Status:date` function.
## Credits
- [yazi source code](https://github.com/sxyazi/yazi)
- [yatline.yazi](https://github.com/imsi32/yatline.yazi/tree/main)
- [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim)
@@ -0,0 +1,217 @@
---@diagnostic disable: undefined-global
local function setup(_, options)
options = options or {}
local default_separators = {
angly = { "", "", "", "" },
curvy = { "", "", "", "" },
liney = { "", "", "|", "|" },
empty = { "", "", "", "" },
}
local separators = default_separators[options.separator_style or "angly"]
local config = {
separator_styles = {
separator_open = options.separator_open or separators[1],
separator_close = options.separator_close or separators[2],
separator_open_thin = options.separator_open_thin or separators[3],
separator_close_thin = options.separator_close_thin or separators[4],
separator_head = options.separator_head or "",
separator_tail = options.separator_tail or "",
},
select_symbol = options.select_symbol or "S",
yank_symbol = options.yank_symbol or "Y",
filename_max_length = options.filename_max_length or 24,
filename_truncate_length = options.filename_truncate_length or 6,
filename_truncate_separator = options.filename_truncate_separator or "...",
color = options.color or nil,
secondary_color = options.secondary_color or nil,
default_files_color = options.default_files_color
or options.secondary_color
or th.which.separator_style:fg()
or "darkgray",
selected_files_color = options.selected_files_color
or th.mgr.count_selected:bg()
or "white",
yanked_files_color = options.yanked_files_color
or th.mgr.count_copied:bg()
or "green",
cut_files_color = options.cut_files_color or th.mgr.count_cut:bg() or "red",
mask_color = th.which.mask:bg() or "black",
}
local current_separator_style = config.separator_styles
function Header:count()
return ui.Line({})
end
function Status:mode()
local mode = tostring(self._tab.mode):upper()
local style = self:style()
return ui.Line({
ui.Span(current_separator_style.separator_head)
:fg(config.color or style.main:bg()),
ui.Span(" " .. mode .. " ")
:fg(config.mask_color)
:bg(config.color or style.main:bg()),
})
end
function Status:length()
local h = self._current.hovered
local len = h and h.cha.len or 0
local style = self:style()
return ui.Span(
current_separator_style.separator_close
.. " "
.. ya.readable_size(len)
.. " "
)
:fg(config.color or style.main:bg())
:bg(config.secondary_color or th.which.separator_style:fg())
end
function Status:utf8_sub(str, start_char, end_char)
local start_byte = utf8.offset(str, start_char)
local end_byte = end_char and (utf8.offset(str, end_char + 1) - 1) or #str
if not start_byte or not end_byte then
return ""
end
return string.sub(str, start_byte, end_byte)
end
function Status:truncate_name(filename, max_length)
local base_name, extension = filename:match("^(.+)(%.[^%.]+)$")
base_name = base_name or filename
extension = extension or ""
if utf8.len(base_name) > max_length then
base_name = self:utf8_sub(base_name, 1, config.filename_truncate_length)
.. config.filename_truncate_separator
.. self:utf8_sub(base_name, -config.filename_truncate_length)
end
return base_name .. extension
end
function Status:name()
local h = self._current.hovered
local style = self:style()
if not h then
return ui.Line({
ui.Span(current_separator_style.separator_close .. " ")
:fg(config.secondary_color or th.which.separator_style:fg()),
ui.Span("Empty dir"):fg(config.color or style.main:bg()),
})
end
local truncated_name =
self:truncate_name(h.name, config.filename_max_length)
return ui.Line({
ui.Span(current_separator_style.separator_close .. " ")
:fg(config.secondary_color or th.which.separator_style:fg()),
ui.Span(truncated_name):fg(config.color or style.main:bg()),
})
end
function Status:files()
local files_yanked = #cx.yanked
local files_selected = #cx.active.selected
local files_cut = cx.yanked.is_cut
local selected_fg = files_selected > 0 and config.selected_files_color
or config.default_files_color
local yanked_fg = files_yanked > 0
and (files_cut and config.cut_files_color or config.yanked_files_color)
or config.default_files_color
local yanked_text = files_yanked > 0
and config.yank_symbol .. " " .. files_yanked
or config.yank_symbol .. " 0"
return ui.Line({
ui.Span(" " .. current_separator_style.separator_close_thin .. " ")
:fg(config.secondary_color or th.which.separator_style:fg()),
ui.Span(config.select_symbol .. " " .. files_selected .. " ")
:fg(selected_fg),
ui.Span(yanked_text .. " "):fg(yanked_fg),
})
end
function Status:modified()
local hovered = cx.active.current.hovered
if not hovered then
return ""
end
local cha = hovered.cha
local time = (cha.mtime or 0) // 1
return ui.Span(
os.date("%Y-%m-%d %H:%M", time)
.. " "
.. current_separator_style.separator_open_thin
.. " "
):fg(config.secondary_color or th.which.separator_style:fg())
end
function Status:percent()
local percent = 0
local cursor = self._tab.current.cursor
local length = #self._tab.current.files
if cursor ~= 0 and length ~= 0 then
percent = math.floor((cursor + 1) * 100 / length)
end
if percent == 0 then
percent = " Top "
elseif percent == 100 then
percent = " Bot "
else
percent = string.format(" %2d%% ", percent)
end
local style = self:style()
return ui.Line({
ui.Span(" " .. current_separator_style.separator_open)
:fg(config.secondary_color or th.which.separator_style:fg()),
ui.Span(percent)
:fg(config.color or style.main:bg())
:bg(config.secondary_color or th.which.separator_style:fg()),
ui.Span(current_separator_style.separator_open)
:fg(config.color or style.main:bg())
:bg(config.secondary_color or th.which.separator_style:fg()),
})
end
function Status:position()
local cursor = self._tab.current.cursor
local length = #self._tab.current.files
local style = self:style()
return ui.Line({
ui.Span(
string.format(" %2d/%-2d ", math.min(cursor + 1, length), length)
)
:fg(config.mask_color)
:bg(config.color or style.main:bg()),
ui.Span(current_separator_style.separator_tail)
:fg(config.color or style.main:bg()),
})
end
Status:children_add(Status.files, 4000, Status.LEFT)
Status:children_add(Status.modified, 0, Status.RIGHT)
end
return { setup = setup }
+35 -1
View File
@@ -136,15 +136,28 @@ fetchers = [
{ url = "local://*", run = "mime.local", prio = "high", group = "mime" }, { url = "local://*", run = "mime.local", prio = "high", group = "mime" },
{ url = "trash://*", run = "mime.trash", prio = "high", group = "mime" }, { url = "trash://*", run = "mime.trash", prio = "high", group = "mime" },
{ url = "remote://*", run = "mime.remote", prio = "high", group = "mime" }, { url = "remote://*", run = "mime.remote", prio = "high", group = "mime" },
# ### current-size ###
# { id = "current-size", name = "*/", run = "current-size", prio = "normal" },
# { id = "current-size", name = "*", run = "current-size", prio = "normal" },
] ]
### git ###
[[plugin.prepend_fetchers]]
url = "*"
run = "git"
group = "git"
[[plugin.prepend_fetchers]]
url = "*/"
run = "git"
group = "git"
### mime-ext ### ### mime-ext ###
[[plugin.prepend_fetchers]] [[plugin.prepend_fetchers]]
url = "local://*" url = "local://*"
run = "mime-ext.local" run = "mime-ext.local"
prio = "high" prio = "high"
group = "mime" group = "mime"
[[plugin.prepend_fetchers]] [[plugin.prepend_fetchers]]
url = "remote://*" url = "remote://*"
run = "mime-ext.remote" run = "mime-ext.remote"
@@ -197,6 +210,16 @@ spotters = [
# Fallback # Fallback
{ url = "*", run = "file" }, { url = "*", run = "file" },
] ]
### extra-metadata ###
[[plugin.append_previewers]]
url = "*"
run = "file-extra-metadata"
# Setup keybind for spotter: https://github.com/sxyazi/yazi/pull/1802
[[plugin.append_spotters]]
url = "*"
run = "file-extra-metadata"
preloaders = [ preloaders = [
# Image # Image
{ mime = "image/{avif,hei?,jxl}", run = "magick" }, { mime = "image/{avif,hei?,jxl}", run = "magick" },
@@ -212,6 +235,17 @@ preloaders = [
# Trash # Trash
{ mime = "trash/**", run = "trash" }, { mime = "trash/**", run = "trash" },
] ]
### exifaudio ###
[[plugin.prepend_previewers]]
mime = "audio/*"
run = "exifaudio"
### eza-preview ###
[[plugin.prepend_previewers]]
url = "*/"
run = "eza-preview"
prepend_previewers = [ prepend_previewers = [
### rich-preview ### ### rich-preview ###
{ url = "*.csv", run = "rich-preview" }, # for csv files { url = "*.csv", run = "rich-preview" }, # for csv files