new yazi config

This commit is contained in:
liph22
2026-01-07 13:07:20 +01:00
parent 8f8400e9d6
commit ee2b1cb5ce
99 changed files with 8516 additions and 4982 deletions

View File

@@ -1,6 +1,6 @@
[phil@liphlink.xyz]
source = imaps://phil%40liphlink.xyz:Fqi5UAyr46e69fG@mail-server.lynx-piano.ts.net:993
outgoing = smtp://phil%40liphlink.xyz:Fqi5UAyr46e69fG@mail-server.lynx-piano.ts.net:587
[phil_live]
source = imaps://phil%40liphlink.xyz:Fqi5UAyr46e69fG@mail.liphlink.xyz:993
outgoing = smtp://phil%40liphlink.xyz:Fqi5UAyr46e69fG@mail.liphlink.xyz:587
default = INBOX
from = Phil <phil@liphlink.xyz>
copy-to = Sent
@@ -9,10 +9,18 @@ postpone = Drafts
folders-sort = INBOX,Draftr,Sent,Archive,Spam,Trash
aliases = pw@liphlink.xyz,p.waibel@liphlink.xyz,philipp.waibel@liphlink.xyz
[phil_notmuch]
source = notmuch://~/Mail/phil
query-map = ~/.config/aerc/notmuch-queries.conf
outgoing = smtp://phil%40liphlink.xyz@mail.liphlink.xyz:587
outgoing-cred-cmd = pass show mail/phil@liphlink.xyz
from = Phil <phil@liphlink.xyz>
default = Inbox
aliases = pw@liphlink.xyz,p.waibel@liphlink.xyz,philipp.waibel@liphlink.xyz
[spam@liphlink.xyz]
source = imaps://spam%40liphlink.xyz:ANZ6JJPBiB7k1c7k@mail-server.lynx-piano.ts.net:993
outgoing = smtp://spam%40liphlink.xyz:ANZ6JJPBiB7k1c7k@mail-server.lynx-piano.ts.net:587
[spam_live]
source = imaps://spam%40liphlink.xyz:ANZ6JJPBiB7k1c7k@mail.liphlink.xyz:993
outgoing = smtp://spam%40liphlink.xyz:ANZ6JJPBiB7k1c7k@mail.liphlink.xyz:587
default = INBOX
from = Liph <spam@liphlink.xyz>
copy-to = Sent
@@ -20,3 +28,23 @@ aliases = pw@liphlink.xyz,p.waibel@liphlink.xyz,philipp.waibel@liphlink.xyz
postpone = Drafts
folders-sort = INBOX,Drafts,Sent,Archive,Spam,Trash
aliases = blue@liphlink.xyz,red@liphlink.xyz
[spam_notmuch]
source = notmuch://~/Mail/spam
query-map = ~/.config/aerc/notmuch-queries.conf
outgoing = smtp://spam%40liphlink.xyz@mail.liphlink.xyz:587
outgoing-cred-cmd = pass show mail/spam@liphlink.xyz
from = Liph <spam@liphlink.xyz>
default = Inbox
aliases = blue@liphlink.xyz,red@liphlink.xyz
[proton]
source = imap+insecure://liiph%40protonmail.com:dRvBWYW3uERY6xqXDgJLeQ@127.0.0.1:1144
outgoing = smtp+insecure://liiph%40protonmail.com:dRvBWYW3uERY6xqXDgJLeQ@127.0.0.1:1026
default = INBOX
from = Liph <spam@liphlink.xyz>
copy-to = Sent
archive = Archive
postpone = Drafts
folders-sort = INBOX,Drafts,Sent,Archive,Spam,Trash
aliases = liiph@proton.me,liiph@pm.me,ph.waibel@proton.me,ph.waibel@pm.me

View File

@@ -576,7 +576,7 @@ sort = -r date
[viewer]
# pager=less -Rc
pager=cat
pager=bat
html-unsafe-images=false
html-filter=dante
image/*=chafa -f kitty -s ${width}x${height}

View File

@@ -15,17 +15,24 @@
[messages]
# Switch between Adresses
,1 = :change-tab phil@liphlink.xyz<Enter>
,2 = :change-tab spam@liphlink.xyz<Enter>
,1 = :change-tab phil_live<Enter>
,2 = :change-tab phil_notmuch<Enter>
,3 = :change-tab spam_live<Enter>
,4 = :change-tab spam_notmuch<Enter>
,5 = :change-tab proton<Enter>
# Delete = move to Trash (syncs with ProtonMail)
d = :move Trash<enter>
# d = :modify -inbox +deleted<Enter>
# a = :modify -inbox<Enter>
# # Delete = tag as deleted and remove from inbox
# d = :tag +deleted -inbox<Enter>
#d = :move Trash<Enter>
D = :delete<Enter>
# # Archive = remove from inbox
# a = :tag -inbox +archive<Enter>
# d = :move Trash<Enter>
# a = :archive flat<Enter>
# Archive
a = :archive flat<Enter>
# Expunge = actually delete (run this in Trash folder)
D = :prompt 'Really delete? ' 'tag +deleted'
# Quick folder navigation
,i = :cf Inbox<Enter>
@@ -39,15 +46,15 @@ a = :archive flat<Enter>
,tr = :cf Trash<Enter>
,a = :cf All Mail<Enter>
o1 = :compose -H "From: Liph \<liiph@proton.me\>"<enter>
o2 = :compose -H "From: Liph \<liiph@protonmail.com\>"<enter>
o3 = :compose -H "From: Liph \<liiph@pm.me\>"<enter>
o4 = :compose -H "From: Philipp Waibel \<ph.waibel@proton.me\>"<enter>
o5 = :compose -H "From: P.Waibel \<ph.waibel@pm.me\>"<enter>
# o1 = :compose -H "From: Liph \<liiph@proton.me\>"<enter>
# o2 = :compose -H "From: Liph \<liiph@protonmail.com\>"<enter>
# o3 = :compose -H "From: Liph \<liiph@pm.me\>"<enter>
# o4 = :compose -H "From: Philipp Waibel \<ph.waibel@proton.me\>"<enter>
# o5 = :compose -H "From: P.Waibel \<ph.waibel@pm.me\>"<enter>
# Delete and sync
#d = :modify-labels +trash -inbox<Enter>:archive flat<Enter>
#d = :modify-labels +deleted -inbox<Enter>
d = :modify-labels +deleted -inbox<Enter>
#d = :modify-labels +deleted -inbox<Enter>
#d = :move Trash<Enter>:exec mbsync -a && notmuch new<Enter>
# Permanently delete (Shift+D)

View File

@@ -1,12 +1,42 @@
Inbox=tag:inbox AND NOT tag:spam
Unread=tag:unread AND NOT tag:spam
Newsletters=tag:newsletter
Shopping=tag:shopping
Finance=tag:finance
Travel=tag:travel
Development=tag:dev
Spam=tag:spam
Sent=tag:sent
Trash=tag:deleted OR folder:Trash
Archive=tag:archive
All Mail=*
# Priority Management
Priority 1=tag:priority1 and tag:inbox
Priority 2=tag:priority2 and tag:inbox
All Priority=tag:priority1 or tag:priority2
# Main Views
Inbox=tag:inbox
Unread=tag:unread
Starred=tag:flagged or tag:starred
Archive=not tag:inbox and not tag:spam and not tag:deleted
Sent=folder:Sent or tag:sent
Drafts=folder:Drafts or tag:draft
Spam=tag:spam or folder:Spam
Trash=tag:deleted or folder:Trash
# Categories
# Work=tag:work and tag:inbox
# Personal=tag:personal and tag:inbox
Finance=tag:finance and tag:inbox
# Social=tag:social and tag:inbox
# Mailing Lists=tag:mailinglist and tag:inbox
Newsletters=tag:newsletter and tag:inbox
# Automated=tag:automated
# Time-based
Today=date:today and tag:inbox
This Week=date:week and tag:inbox
This Month=date:month and tag:inbox
Last 7 Days=date:7days..today
# Special Queries
Needs Reply=tag:inbox and not tag:replied
Attachments=tag:attachment and tag:inbox
Important=tag:flagged or tag:priority1
Action Required=tag:todo or tag:followup
# Unprocessed
New Mail=tag:new
Untagged=tag:inbox and not tag:priority1 and not tag:priority2 and not tag:work and not tag:personal and not tag:finance
# All Mail
Everything=*

View File

@@ -1,4 +1,4 @@
theme = catppuccin-mocha
# theme = catppuccin-mocha
# font-size = 12
# background-blur-radius = 20
# mouse-hide-while-typing = true
@@ -76,7 +76,7 @@ keybind = super+b>n=new_window
#keybind = super+a>l=goto_split:right
# typecraft
theme = catppuccin-mocha
# theme = catppuccin-mocha
# theme = GruvboxDark
font-family = CaskaydiaCove Nerd Font
font-size = 12

View File

@@ -19,7 +19,7 @@
# source = ~/.config/hypr/myColors.conf
# Wallpaper
env = WALLPAPER, ~/.config/backgrounds/unviverse/magenta.jpg
env = WALLPAPER, /home/liph/.config/backgrounds/unviverse/magenta.jpg
################
### MONITORS ###

View File

@@ -1,2 +1,4 @@
preload = $WALLPAPER
wallpaper = , $WALLPAPER
wallpaper {
monitor =
path = $WALLPAPER
}

109
scripts/scripts/bw-fzf.sh Executable file
View File

@@ -0,0 +1,109 @@
#!/bin/bash
if [ -z "$BW_SESSION" ]; then
export BW_SESSION=$(bw unlock --raw)
fi
items=$(bw list items)
# Select item with preview showing full details
selected=$(echo "$items" | jq -r '.[] | "\(.name)\t\(.login.username // "no username")"' | \
column -t -s $'\t' | \
fzf --preview 'name=$(echo {} | awk "{print \$1}"); bw get item "$name" 2>/dev/null | jq -r "
\"Name: \" + .name,
\"Type: \" + (.type | tostring),
\"---\",
(if .login then
\"Username: \" + (.login.username // \"none\"),
\"Password: \" + (if .login.password then \"********\" else \"none\" end),
(if .login.uris then \"URIs:\", (.login.uris[] | \" - \" + .uri) else empty end),
(if .login.totp then \"TOTP: configured\" else empty end)
else empty end),
(if .notes then \"---\", \"Notes:\", .notes else empty end),
(if .fields then \"---\", \"Custom Fields:\", (.fields[] | \" \" + .name + \": \" + (if .type == 1 then \"********\" else (.value // \"empty\") end)) else empty end)
" | cat' --preview-window=right:60%:wrap)
if [ -n "$selected" ]; then
name=$(echo "$selected" | awk '{print $1}')
# Get full item details
item=$(bw get item "$name" 2>/dev/null)
if [ -z "$item" ]; then
notify-send "Bitwarden" "Failed to get item for $name"
exit 1
fi
# Build a list of available fields
fields=()
if echo "$item" | jq -e '.login.password' &>/dev/null; then
fields+=("Password")
fi
if echo "$item" | jq -e '.login.username' &>/dev/null; then
fields+=("Username")
fi
if echo "$item" | jq -e '.login.uris[]' &>/dev/null; then
fields+=("URI")
fi
if echo "$item" | jq -e '.login.totp' &>/dev/null; then
fields+=("TOTP Code")
fi
if echo "$item" | jq -e '.notes' &>/dev/null; then
notes=$(echo "$item" | jq -r '.notes')
if [ -n "$notes" ] && [ "$notes" != "null" ]; then
fields+=("Notes")
fi
fi
if echo "$item" | jq -e '.fields[]' &>/dev/null; then
while IFS= read -r field_name; do
fields+=("Custom: $field_name")
done < <(echo "$item" | jq -r '.fields[] | .name')
fi
fields+=("View All (JSON)")
# Let user choose what to copy
choice=$(printf '%s\n' "${fields[@]}" | fzf --prompt="What to copy? ")
if [ -n "$choice" ]; then
case "$choice" in
"Password")
echo "$item" | jq -r '.login.password' | wl-copy
notify-send "Bitwarden" "Password copied for $name"
;;
"Username")
echo "$item" | jq -r '.login.username' | wl-copy
notify-send "Bitwarden" "Username copied for $name"
;;
"URI")
echo "$item" | jq -r '.login.uris[0].uri' | wl-copy
notify-send "Bitwarden" "URI copied for $name"
;;
"TOTP Code")
totp=$(bw get totp "$name" 2>/dev/null)
echo -n "$totp" | wl-copy
notify-send "Bitwarden" "TOTP code copied for $name"
;;
"Notes")
echo "$item" | jq -r '.notes' | wl-copy
notify-send "Bitwarden" "Notes copied for $name"
;;
Custom:*)
field_name="${choice#Custom: }"
value=$(echo "$item" | jq -r --arg name "$field_name" '.fields[] | select(.name == $name) | .value')
echo -n "$value" | wl-copy
notify-send "Bitwarden" "Custom field '$field_name' copied"
;;
"View All (JSON)")
echo "$item" | jq '.' | wl-copy
notify-send "Bitwarden" "Full item JSON copied for $name"
;;
esac
fi
fi

View File

@@ -0,0 +1,19 @@
#!/bin/bash
echo "=== Syncing all mailboxes ==="
# 1. Sync emails bidirectionally (includes deletions)
mbsync -a
# 2. Index each account separately (runs post-new hook)
for account in phil spam; do
echo "Indexing $account..."
NOTMUCH_CONFIG=~/Mail/$account/.notmuch-config notmuch new
done
# 3. Optional: Sync back any tag changes to IMAP flags
for account in phil spam; do
NOTMUCH_CONFIG=~/Mail/$account/.notmuch-config notmuch tag --batch < /dev/null
done
echo "=== Sync complete ==="

View File

@@ -12,7 +12,15 @@ set -g pane-base-index 1
set-window-option -g pane-base-index 1
set-option -g renumber-windows on
set -g allow-passthrough on
# set -g allow-passthrough on
# Allow Kitty graphics protocol to pass through
set -gq allow-passthrough on
# Tell applications we're running in Kitty
set -g default-terminal "tmux-256color"
set -as terminal-features ',kitty:RGB'
set -as terminal-overrides ',kitty:Tc'
bind-key h select-pane -L
bind-key j select-pane -D

View File

@@ -1,17 +0,0 @@
tank /mnt/tank/ t
ssd2 /mnt/ssd2/ 7
ssd1 /mnt/ssd1/ 6
obsidian /home/liph/Documents/obsidian/vault/ o
nvim /home/liph/.config/nvim/ n
liph /home/liph/ l
hypr /home/liph/.config/hypr/ h
healing /mnt/tank/audio/healing/ H
hdd5 /mnt/hdd5/ 5
hdd4 /mnt/hdd4/ 4
hdd3 /mnt/hdd3/ 3
hdd2 /mnt/hdd2/ 2
hdd1 /mnt/hdd1/ 1
flash1 /mnt/flash1/ 8
Downloads /home/liph/Downloads/ D
dotfiles /home/liph/dotfiles/ d
.config /home/liph/.config/ c

View File

@@ -1,38 +0,0 @@
<div align="center">
<img src="https://github.com/sxyazi/yazi/blob/main/assets/logo.png?raw=true" alt="Yazi logo" width="20%">
</div>
<h3 align="center">
Catppuccin Mocha Flavor for <a href="https://github.com/sxyazi/yazi">Yazi</a>
</h3>
## 👀 Preview
<img src="preview.png" width="600" />
## 🎨 Installation
```sh
ya pack -a yazi-rs/flavors:catppuccin-mocha
```
## ⚙️ Usage
Set the content of your `theme.toml` to enable it as your _dark_ flavor:
```toml
[flavor]
use = "catppuccin-mocha"
# For upcoming Yazi 0.4 (nightly version):
dark = "catppuccin-mocha"
```
Make sure your `theme.toml` doesn't contain anything other than `[flavor]`, unless you want to override certain styles of this flavor.
See the [Yazi flavor documentation](https://yazi-rs.github.io/docs/flavors/overview) for more details.
## 📜 License
The flavor is MIT-licensed, and the included tmTheme is also MIT-licensed.
Check the [LICENSE](LICENSE) and [LICENSE-tmtheme](LICENSE-tmtheme) file for more details.

View File

@@ -1,173 +0,0 @@
# vim:fileencoding=utf-8:foldmethod=marker
# : Manager {{{
[manager]
cwd = { fg = "#94e2d5" }
# Hovered
hovered = { reversed = true }
preview_hovered = { underline = true }
# Find
find_keyword = { fg = "#f9e2af", bold = true, italic = true, underline = true }
find_position = { fg = "#f5c2e7", bg = "reset", bold = true, italic = true }
# Marker
marker_copied = { fg = "#a6e3a1", bg = "#a6e3a1" }
marker_cut = { fg = "#f38ba8", bg = "#f38ba8" }
marker_marked = { fg = "#94e2d5", bg = "#94e2d5" }
marker_selected = { fg = "#f9e2af", bg = "#f9e2af" }
# Tab
tab_active = { reversed = true }
tab_inactive = {}
tab_width = 1
# Count
count_copied = { fg = "#1e1e2e", bg = "#a6e3a1" }
count_cut = { fg = "#1e1e2e", bg = "#f38ba8" }
count_selected = { fg = "#1e1e2e", bg = "#f9e2af" }
# Border
border_symbol = "│"
border_style = { fg = "#7f849c" }
# : }}}
# : Mode {{{
[mode]
normal_main = { fg = "#1e1e2e", bg = "#89b4fa", bold = true }
normal_alt = { fg = "#89b4fa", bg = "#313244" }
# Select mode
select_main = { fg = "#1e1e2e", bg = "#a6e3a1", bold = true }
select_alt = { fg = "#a6e3a1", bg = "#313244" }
# Unset mode
unset_main = { fg = "#1e1e2e", bg = "#f2cdcd", bold = true }
unset_alt = { fg = "#f2cdcd", bg = "#313244" }
# : }}}
# : Status bar {{{
[status]
separator_open = ""
separator_close = ""
# Progress
progress_label = { fg = "#ffffff", bold = true }
progress_normal = { fg = "#89b4fa", bg = "#45475a" }
progress_error = { fg = "#f38ba8", bg = "#45475a" }
# Permissions
perm_sep = { fg = "#7f849c" }
perm_type = { fg = "#89b4fa" }
perm_read = { fg = "#f9e2af" }
perm_write = { fg = "#f38ba8" }
perm_exec = { fg = "#a6e3a1" }
# : }}}
# : Pick {{{
[pick]
border = { fg = "#89b4fa" }
active = { fg = "#f5c2e7", bold = true }
inactive = {}
# : }}}
# : Input {{{
[input]
border = { fg = "#89b4fa" }
title = {}
value = {}
selected = { reversed = true }
# : }}}
# : Completion {{{
[completion]
border = { fg = "#89b4fa" }
# : }}}
# : Tasks {{{
[tasks]
border = { fg = "#89b4fa" }
title = {}
hovered = { fg = "#f5c2e7", underline = true }
# : }}}
# : Which {{{
[which]
mask = { bg = "#313244" }
cand = { fg = "#94e2d5" }
rest = { fg = "#9399b2" }
desc = { fg = "#f5c2e7" }
separator = "  "
separator_style = { fg = "#585b70" }
# : }}}
# : Help {{{
[help]
on = { fg = "#94e2d5" }
run = { fg = "#f5c2e7" }
hovered = { reversed = true, bold = true }
footer = { fg = "#313244", bg = "#cdd6f4" }
# : }}}
# : Notify {{{
[notify]
title_info = { fg = "#a6e3a1" }
title_warn = { fg = "#f9e2af" }
title_error = { fg = "#f38ba8" }
# : }}}
# : File-specific styles {{{
[filetype]
rules = [
# Images
{ mime = "image/*", fg = "#94e2d5" },
# Media
{ mime = "{audio,video}/*", fg = "#f9e2af" },
# Archives
{ mime = "application/{zip,rar,7z*,tar,gzip,xz,zstd,bzip*,lzma,compress,archive,cpio,arj,xar,ms-cab*}", fg = "#f5c2e7" },
# Documents
{ mime = "application/{pdf,doc,rtf}", fg = "#a6e3a1" },
# Fallback
{ name = "*", fg = "#cdd6f4" },
{ name = "*/", fg = "#89b4fa" }
]
# : }}}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 660 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,185 @@
-- git-yazi plugin
-- th.git = th.git or {}
-- th.git.modified = ui.Style():fg("blue")
-- th.git.deleted = ui.Style():fg("red"):bold()
require("git"):setup()
-- whoosh plugin
-- You can configure your bookmarks using simplified syntax
-- local bookmarks = {
-- { tag = "Documents", path = "~/Documents", key = "D" },
-- }
-- You can also configure bookmarks with key arrays
-- local bookmarks = {
-- { tag = "Desktop", path = "~/Desktop", key = { "d", "D" } },
-- { tag = "Documents", path = "~/Documents", key = { "d", "d" } },
-- { tag = "Downloads", path = "~/Downloads", key = "o" },
-- { tag = "Downloads", path = "~/Downloads", key = "o" },
-- { tag = "Downloads", path = "~/Downloads", key = "o" },
-- { tag = "Downloads", path = "~/Downloads", key = "o" },
-- { tag = "Downloads", path = "~/Downloads", key = "o" },
-- }
require("whoosh"):setup({
-- Configuration bookmarks (cannot be deleted through plugin)
bookmarks = bookmarks,
-- Notification settings
jump_notify = false,
-- Key generation for auto-assigning bookmark keys
keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
-- Configure the built-in menu action hotkeys
-- false - hide menu item
special_keys = {
create_temp = "<Enter>", -- Create a temporary bookmark from the menu
fuzzy_search = "<Space>", -- Launch fuzzy search (fzf)
history = "<Tab>", -- Open directory history
previous_dir = "<Backspace>", -- Jump back to the previous directory
},
-- File path for storing user bookmarks
bookmarks_path = (
ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\plugins\\whoosh.yazi\\bookmarks"
) or (os.getenv("HOME") .. "/.config/yazi/plugins/whoosh.yazi/bookmarks"),
-- Replace home directory with "~"
home_alias_enabled = true, -- Toggle home aliasing in displays
-- Path truncation in navigation menu
path_truncate_enabled = false, -- Enable/disable path truncation
path_max_depth = 3, -- Maximum path depth before truncation
-- Path truncation in fuzzy search (fzf)
fzf_path_truncate_enabled = false, -- Enable/disable path truncation in fzf
fzf_path_max_depth = 5, -- Maximum path depth before truncation in fzf
-- Long folder name truncation
path_truncate_long_names_enabled = false, -- Enable in navigation menu
fzf_path_truncate_long_names_enabled = false, -- Enable in fzf
path_max_folder_name_length = 20, -- Max length in navigation menu
fzf_path_max_folder_name_length = 20, -- Max length in fzf
-- History directory settings
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_max_depth = 5, -- Maximum path depth before truncation for history (default 5)
history_fzf_path_truncate_long_names_enabled = false, -- Enable/disable long folder name truncation for history
history_fzf_path_max_folder_name_length = 30, -- Maximum length for folder names in history (default 30)
})
-- projetc plugin
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",
},
})
-- yafg plugin
require("yafg"):setup({
editor = "nvim", -- Editor command (default: "hx")
args = { "--noplugin" }, -- Additional editor arguments (default: {})
file_arg_format = "+{row} {file}", -- File argument format (default: "{file}:{row}:{col}")
})
require("simple-tag"):setup({
-- UI display mode (icon, text, hidden)
ui_mode = "icon", -- (Optional)
-- Disable tag key hints (popup in bottom right corner)
hints_disabled = false, -- (Optional)
-- linemode order: adjusts icon/text position. For example, if you want icon to be on the most left of linemode then set linemode_order larger than 1000.
-- More info: https://github.com/sxyazi/yazi/blob/077faacc9a84bb5a06c5a8185a71405b0cb3dc8a/yazi-plugin/preset/components/linemode.lua#L4-L5
linemode_order = 500, -- (Optional)
-- You can backup/restore this folder within the same OS (Linux, windows, or MacOS).
-- But you can't restore backed up folder in the different OS because they use difference absolute path.
-- save_path = -- full path to save tags folder (Optional)
-- - Linux/MacOS: os.getenv("HOME") .. "/.config/yazi/tags"
-- - Windows: os.getenv("APPDATA") .. "\\yazi\\config\\tags"
-- Set tag colors
colors = { -- (Optional)
-- Set this same value with `theme.toml` > [mgr] > hovered > reversed
-- Default theme use "reversed = true".
-- More info: https://github.com/sxyazi/yazi/blob/077faacc9a84bb5a06c5a8185a71405b0cb3dc8a/yazi-config/preset/theme-dark.toml#L25
reversed = true, -- (Optional)
-- More colors: https://yazi-rs.github.io/docs/configuration/theme#types.color
-- format: [tag key] = "color"
["*"] = "#bf68d9", -- (Optional)
["$"] = "green",
["!"] = "#cc9057",
["1"] = "cyan",
["p"] = "red",
},
-- Set tag icons. Only show when ui_mode = "icon".
-- Any text or nerdfont icons should work as long as you use nerdfont to render yazi.
-- Default icon from mactag.yazi: ●; Some generic icons: , , 󱈤
-- More icon from nerd fonts: https://www.nerdfonts.com/cheat-sheet
icons = { -- (Optional)
-- default icon
default = "󰚋",
-- format: [tag key] = "tag icon"
["*"] = "*",
["$"] = "",
["!"] = "",
["p"] = "",
},
})
require("yaziline"):setup({
color = "#98c379", -- main theme color
color = "#f9e2af",
secondary_color = "#5A6078",
default_files_color = "darkgray", -- color of the file counter when it's inactive
selected_files_color = "white",
yanked_files_color = "green",
yanked_files_color = "blue",
cut_files_color = "red",
separator_style = "angly", -- "angly" | "curvy" | "liney" | "empty"
@@ -18,70 +195,5 @@ require("yaziline"):setup({
filename_max_length = 24, -- truncate when filename > 24
filename_truncate_length = 6, -- leave 6 chars on both sides
filename_truncate_separator = "..." -- the separator of the truncated filename
filename_truncate_separator = "...",
})
local path_sep = package.config:sub(1, 1)
local home_path = ya.target_family() == "windows" and os.getenv("USERPROFILE") or os.getenv("HOME")
if ya.target_family() == "windows" then
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"
})
table.insert(bookmarks, {
tag = "Desktop",
path = home_path .. path_sep .. "Desktop" .. path_sep,
key = "d"
})
end
-- You can configure your bookmarks by lua language
local bookmarks = {}
local path_sep = package.config:sub(1, 1)
local home_path = ya.target_family() == "windows" and os.getenv("USERPROFILE") or os.getenv("HOME")
if ya.target_family() == "windows" then
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
table.insert(bookmarks, {
tag = "Desktop",
path = home_path .. path_sep .. "Desktop" .. path_sep,
key = "d"
})
require("git"):setup()
require("yamb"):setup {
-- Optional, the path ending with path seperator represents folder.
bookmarks = bookmarks,
-- Optional, recieve notification everytime you jump.
jump_notify = true,
-- Optional, the cli of fzf.
cli = "fzf",
-- Optional, a string used for randomly generating keys, where the preceding characters have higher priority.
keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
-- Optional, the path of bookmarks
path = (ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\bookmark") or
(os.getenv("HOME") .. "/.config/yazi/bookmark"),
}
-- require("fg"):setup({
-- default_action = "menu", -- nvim, jump
-- })

View File

@@ -1,385 +1,314 @@
# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
"$schema" = "https://yazi-rs.github.io/schemas/keymap.json"
[mgr]
keymap = [
{ on = "<Esc>", run = "escape", desc = "Exit visual mode, clear selected, or cancel search" },
{ on = "<C-[>", run = "escape", desc = "Exit visual mode, clear selected, or cancel search" },
{ on = "q", run = "quit", desc = "Quit the process" },
{ on = "Q", run = "quit --no-cwd-file", desc = "Quit the process without outputting cwd-file" },
{ on = "<C-c>", run = "close", desc = "Close the current tab, or quit if it's last" },
{ on = "<C-z>", run = "suspend", desc = "Suspend the process" },
# Hopping
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<C-j>", run = "arrow -50%", desc = "Move cursor up half page" },
{ on = "<C-k>", run = "arrow 50%", desc = "Move cursor down half page" },
{ on = "<C-h>", run = "arrow -100%", desc = "Move cursor up one page" },
{ on = "<C-l>", run = "arrow 100%", desc = "Move cursor down one page" },
{ on = "<S-PageUp>", run = "arrow -50%", desc = "Move cursor up half page" },
{ on = "<S-PageDown>", run = "arrow 50%", desc = "Move cursor down half page" },
{ on = "<PageUp>", run = "arrow -100%", desc = "Move cursor up one page" },
{ on = "<PageDown>", run = "arrow 100%", desc = "Move cursor down one page" },
{ on = [ "g", "g" ], run = "arrow top", desc = "Move cursor to the top" },
{ on = "G", run = "arrow bot", desc = "Move cursor to the bottom" },
# Navigation
{ on = "h", run = "leave", desc = "Go back to the parent directory" },
{ on = "l", run = "enter", desc = "Enter the child directory" },
{ on = "<Left>", run = "leave", desc = "Go back to the parent directory" },
{ on = "<Right>", run = "enter", desc = "Enter the child directory" },
{ on = "H", run = "back", desc = "Go back to the previous directory" },
{ on = "L", run = "forward", desc = "Go forward to the next directory" },
# Toggle
{ on = "<Space>", run = [ "toggle", "arrow 1" ], desc = "Toggle the current selection state" },
{ on = "<C-a>", run = "toggle_all --state=on", desc = "Select all files" },
{ on = "<C-r>", run = "toggle_all", desc = "Invert selection of all files" },
# Visual mode
{ on = "v", run = "visual_mode", desc = "Enter visual mode (selection mode)" },
{ on = "V", run = "visual_mode --unset", desc = "Enter visual mode (unset mode)" },
# Seeking
{ on = "K", run = "seek -5", desc = "Seek up 5 units in the preview" },
{ on = "J", run = "seek 5", desc = "Seek down 5 units in the preview" },
# Spotting
{ on = "<Tab>", run = "spot", desc = "Spot hovered file" },
# Operation
{ on = "o", run = "open", desc = "Open selected files" },
{ on = "O", run = "open --interactive", desc = "Open selected files interactively" },
{ on = "<Enter>", run = "open", desc = "Open selected files" },
{ on = "<S-Enter>", run = "open --interactive", desc = "Open selected files interactively" },
{ on = "y", run = "yank", desc = "Yank selected files (copy)" },
{ on = "x", run = "yank --cut", desc = "Yank selected files (cut)" },
{ on = "p", run = "paste", desc = "Paste yanked files" },
{ on = "P", run = "paste --force", desc = "Paste yanked files (overwrite if the destination exists)" },
{ on = "-", run = "link", desc = "Symlink the absolute path of yanked files" },
{ on = "_", run = "link --relative", desc = "Symlink the relative path of yanked files" },
{ on = "<C-->", run = "hardlink", desc = "Hardlink yanked files" },
{ on = "Y", run = "unyank", desc = "Cancel the yank status" },
{ on = "X", run = "unyank", desc = "Cancel the yank status" },
{ on = "d", run = "remove", desc = "Trash selected files" },
{ on = "D", run = "remove --permanently", desc = "Permanently delete selected files" },
{ on = "a", run = "create", desc = "Create a file (ends with / for directories)" },
{ on = "r", run = "rename --cursor=before_ext", desc = "Rename selected file(s)" },
{ on = ";", run = "shell --interactive", desc = "Run a shell command" },
{ on = ":", run = "shell --block --interactive", desc = "Run a shell command (block until finishes)" },
{ on = ".", run = "hidden toggle", desc = "Toggle the visibility of hidden files" },
{ on = "s", run = "search --via=fd", desc = "Search files by name via fd" },
{ on = "S", run = "search --via=rg", desc = "Search files by content via ripgrep" },
{ on = "<C-s>", run = "escape --search", desc = "Cancel the ongoing search" },
{ on = "z", run = "plugin zoxide", desc = "Jump to a directory via zoxide" },
{ on = "Z", run = "plugin fzf", desc = "Jump to a file/directory via fzf" },
# Linemode
{ on = [ "m", "s" ], run = "linemode size", desc = "Linemode: size" },
{ on = [ "m", "p" ], run = "linemode permissions", desc = "Linemode: permissions" },
{ on = [ "m", "b" ], run = "linemode btime", desc = "Linemode: btime" },
{ on = [ "m", "m" ], run = "linemode mtime", desc = "Linemode: mtime" },
{ on = [ "m", "o" ], run = "linemode owner", desc = "Linemode: owner" },
{ on = [ "m", "n" ], run = "linemode none", desc = "Linemode: none" },
# Copy
{ on = [ "c", "c" ], run = "copy path", desc = "Copy the file path" },
{ on = [ "c", "d" ], run = "copy dirname", desc = "Copy the directory path" },
{ on = [ "c", "f" ], run = "copy filename", desc = "Copy the filename" },
{ on = [ "c", "n" ], run = "copy name_without_ext", desc = "Copy the filename without extension" },
# Filter
{ on = "f", run = "filter --smart", desc = "Filter files" },
# Find
{ on = "/", run = "find --smart", desc = "Find next file" },
{ on = "?", run = "find --previous --smart", desc = "Find previous file" },
{ on = "n", run = "find_arrow", desc = "Goto the next found" },
{ on = "N", run = "find_arrow --previous", desc = "Goto the previous found" },
# Sorting
{ on = [ ",", "m" ], run = [ "sort mtime --reverse=no", "linemode mtime" ], desc = "Sort by modified time" },
{ on = [ ",", "M" ], run = [ "sort mtime --reverse", "linemode mtime" ], desc = "Sort by modified time (reverse)" },
{ on = [ ",", "b" ], run = [ "sort btime --reverse=no", "linemode btime" ], desc = "Sort by birth time" },
{ on = [ ",", "B" ], run = [ "sort btime --reverse", "linemode btime" ], desc = "Sort by birth time (reverse)" },
{ on = [ ",", "e" ], run = "sort extension --reverse=no", desc = "Sort by extension" },
{ on = [ ",", "E" ], run = "sort extension --reverse", desc = "Sort by extension (reverse)" },
{ on = [ ",", "a" ], run = "sort alphabetical --reverse=no", desc = "Sort alphabetically" },
{ on = [ ",", "A" ], run = "sort alphabetical --reverse", desc = "Sort alphabetically (reverse)" },
{ on = [ ",", "n" ], run = "sort natural --reverse=no", desc = "Sort naturally" },
{ on = [ ",", "N" ], run = "sort natural --reverse", desc = "Sort naturally (reverse)" },
{ on = [ ",", "s" ], run = [ "sort size --reverse=no", "linemode size" ], desc = "Sort by size" },
{ on = [ ",", "S" ], run = [ "sort size --reverse", "linemode size" ], desc = "Sort by size (reverse)" },
{ on = [ ",", "r" ], run = "sort random --reverse=no", desc = "Sort randomly" },
# Tabs
{ on = "t", run = "tab_create --current", desc = "Create a new tab with CWD" },
{ on = "1", run = "tab_switch 0", desc = "Switch to the first tab" },
{ on = "2", run = "tab_switch 1", desc = "Switch to the second tab" },
{ on = "3", run = "tab_switch 2", desc = "Switch to the third tab" },
{ on = "4", run = "tab_switch 3", desc = "Switch to the fourth tab" },
{ on = "5", run = "tab_switch 4", desc = "Switch to the fifth tab" },
{ on = "6", run = "tab_switch 5", desc = "Switch to the sixth tab" },
{ on = "7", run = "tab_switch 6", desc = "Switch to the seventh tab" },
{ on = "8", run = "tab_switch 7", desc = "Switch to the eighth tab" },
{ on = "9", run = "tab_switch 8", desc = "Switch to the ninth tab" },
{ on = "[", run = "tab_switch -1 --relative", desc = "Switch to the previous tab" },
{ on = "]", run = "tab_switch 1 --relative", desc = "Switch to the next tab" },
{ on = "{", run = "tab_swap -1", desc = "Swap current tab with previous tab" },
{ on = "}", run = "tab_swap 1", desc = "Swap current tab with next tab" },
# Tasks
{ on = "w", run = "tasks_show", desc = "Show task manager" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
]
# eza keymaps https://github.com/ahkohd/eza-preview.yazi
prepend_keymap = [
{ on = [ "<C-p>" ], run = "plugin eza-preview", desc = "Toggle tree/list dir preview" },
{ on = [ "<C-0" ], run = "plugin eza-preview '--inc-level'", desc = "Increment tree level" },
{ on = [ "<C-ö>" ], run = "plugin eza-preview '--dec-level'", desc = "Decrement tree level" },
{ on = [ "<C-o>" ], run = "plugin eza-preview '--toggle-follow-symlinks'", desc = "Toggle tree follow symlinks" },
# ouch https://github.com/ndtoan96/ouch.yazi
{ on = ["C"], run = "plugin ouch 'zip'", desc = "Compress with ouch" },
# https://github.com/iynaix/time-travel.yazi
{ on = ["W", "h"], run = "plugin time-travel 'prev'", desc = "Go to previous snapshot"},
{ on = ["W", "l"], run = "plugin time-travel 'next'", desc = "Go to next snapshot"},
{ on = ["W", "e"], run = "plugin time-travel 'exit'", desc = "Exit browsing snapshots"},
# https://github.com/Lil-Dank/lazygit.yazi
{ on = [ "g", "i" ], run = "plugin lazygit", desc = "run lazygit"},
# mount
{ on = "M", run = "plugin mount" },
# yamb.yazi https://github.com/h-hg/yamb.yazi
{ on = [ "u", "a" ], run = "plugin yamb 'save'", desc = "Add bookmark"},
{ on = [ "u", "g" ], run = "plugin yamb 'jump_by_key'", desc = "Jump bookmark by key"},
{ on = [ "u", "G" ], run = "plugin yamb 'jump_by_fzf'", desc = "Jump bookmark by fzf"},
{ on = [ "u", "d" ], run = "plugin yamb 'delete_by_key'", desc = "Delete bookmark by key"},
{ on = [ "u", "D" ], run = "plugin yamb 'delete_by_fzf'", desc = "Delete bookmark by fzf"},
{ on = [ "u", "A" ], run = "plugin yamb 'delete_all'", desc = "Delete all bookmarks"},
{ on = [ "u", "r" ], run = "plugin yamb 'rename_by_key'", desc = "Rename bookmark by key"},
{ on = [ "u", "R" ], run = "plugin yamb 'rename_by_fzf'", desc = "Rename bookmark by fzf"},
# chmode https://github.com/yazi-rs/plugins/tree/main/chmod.yazi
{ on = [ "c", "m" ], run = "plugin chmod", desc = "Chmod on selected files" },
# https://gitee.com/DreamMaoMao/fg.yazi
{ on = [ "f","g" ], run = "plugin fg", desc = "find file by content (fuzzy match)" },
{ on = [ "f","G" ], run = "plugin fg 'rg'", desc = "find file by content (ripgrepmatch)" },
{ on = [ "f","f" ], run = "plugin fg 'fzf'", desc = "find file by filename" },
# toggle view
{ on = [ "i", "a" ], run = "plugin toggle-view 'parent'", desc = "Toggle parent" },
{ on = [ "i", "s" ], run = "plugin toggle-view 'current'", desc = "Toggle current" },
{ on = [ "i", "d"], run = "plugin toggle-view 'preview'", desc = "Toggle preview" },
]
# rsync plugin
{on = [ "R" ], run = "plugin rsync", desc = "Copy files using rsync"},
# yafg plugin
{ on = [ "F", "G" ], run = "plugin yafg"},
# lazygit plugin
{on = [ "g", "i" ], run = "plugin lazygit", desc = "run lazygit"},
# mount plugin
{ on = "M", run = "plugin mount"},
# smart-enter plugin
{ on = "l", run = "plugin smart-enter", desc = "Enter the child directory, or open the file"},
# jump-to-char plugin
{ on = "f", run = "plugin jump-to-char", desc = "Jump to char" },
# whoosh plugin
{ on = "[", run = "plugin whoosh jump_by_key", desc = "Jump bookmark by key"},
# Direct fuzzy search access
{ on = "}", run = "plugin whoosh jump_by_fzf", desc = "Direct fuzzy search for bookmarks"},
# Basic bookmark operations
{ on = [ "]", "a" ], run = "plugin whoosh save", desc = "Add bookmark (hovered file/directory)"},
{ on = [ "]", "A" ], run = "plugin whoosh save_cwd", desc = "Add bookmark (current directory)"},
## Temporary bookmarks
{ on = [ "]", "t" ], run = "plugin whoosh save_temp", desc = "Add temporary bookmark (hovered file/directory)"},
{ on = [ "]", "T" ], run = "plugin whoosh save_cwd_temp", desc = "Add temporary bookmark (current directory)"},
## Jump to bookmarks
{ on = "<A-k>", run = "plugin whoosh jump_key_k", desc = "Jump directly to bookmark with key k"},
{ on = [ "]", "f" ], run = "plugin whoosh jump_by_fzf", desc = "Jump bookmark by fzf"},
## Delete bookmarks
{ on = [ "]", "d" ], run = "plugin whoosh delete_by_key", desc = "Delete bookmark by key"},
{ on = [ "]", "D" ], run = "plugin whoosh delete_by_fzf", desc = "Delete bookmarks by fzf (use TAB to select multiple)"},
{ on = [ "]", "C" ], run = "plugin whoosh delete_all", desc = "Delete all user bookmarks"},
## Rename Bookmarks
{ on = [ "]", "r" ], run = "plugin whoosh rename_by_key", desc = "Rename bookmark by key"},
{ on = [ "]", "R" ], run = "plugin whoosh rename_by_fzf", desc = "Rename bookmark by fzf"},
# Navigation
{ on = ["<Esc>"], run = "escape", desc = "Exit visual mode, clear selected, or cancel search" },
{ on = ["q"], run = "quit", desc = "Exit the process" },
{ on = ["<C-q>"], run = "close", desc = "Close the current tab, or quit if it is last tab" },
# projects plugin
{on = [ "P", "p" ], run = "plugin projects 'load SomeProject'", desc = "Load the 'SomeProject' project"},
{on = [ "P", "s" ], run = "plugin projects save", desc = "Save current project"},
{on = [ "P", "l" ], run = "plugin projects load", desc = "Load project"},
{on = [ "P", "P" ], run = "plugin projects load_last", desc = "Load last project"},
{on = [ "P", "d" ], run = "plugin projects delete", desc = "Delete project"},
{on = [ "P", "D" ], run = "plugin projects delete_all", desc = "Delete all projects"},
{on = [ "P", "m" ], run = "plugin projects 'merge current'", desc = "Merge current tab to other projects"},
{on = [ "P", "M" ], run = "plugin projects 'merge all'", desc = "Merge current project to other projects"},
# fazif plugin
{on = [ "b", "d" ], run = "plugin fazif faziffd", desc = "Find files/directories with fd and fzf"},
{on = [ "b", "D" ], run = "plugin fazif faziffdr", desc = "Find files/directories with fd and fzf"},
{on = [ "b", "r" ], run = "plugin fazif fazifrg", desc = "Find content in files with ripgrep and fzf"},
{on = [ "b", "R" ], run = "plugin fazif fazifrga", desc = "Find content in documents with ripgrep-all and fzf"},
# Tagging plugin
#─────────────────────────── TOGGLE TAG(S) ────────────────────────────
# Toggle a tag (press any tag key)
# A tag hint window will show up.
# Simply press any tag key to toggle that tag for selected or hovered files/folders.
{ on = [ "t", "t", "k" ], run = "plugin simple-tag -- toggle-tag", desc = "Toggle a tag (press any key)" },
# Fast Toggle tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
# NOTE: For key=" (Quotation mark), then use key=\" (Backslash + Quotation mark) instead.
{ on = [ "`" ], run = "plugin simple-tag -- toggle-tag --keys=!1q", desc = "Toggle tag(s) with fixed tag key(s) = (! and 1 and q)" },
# { on = [ "`" ], run = "plugin simple-tag -- toggle-tag --keys=*", desc = "Toggle tag with fixed tag key = *" },
# { on = [ "`" ], run = "plugin simple-tag -- toggle-tag --key=*", desc = "Toggle tag with fixed tag key = *" },
# Toggle tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input tag key(s) to toggle that tags for selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "t", "i" ], run = "plugin simple-tag -- toggle-tag --input", desc = "Toggle tag(s) with value from (input box)" },
#─────────────────────────── ADD TAG(S) ───────────────────────────────
# Add a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key to add to selected or hovered files/folders.
{ on = [ "t", "a", "k" ], run = "plugin simple-tag -- add-tag", desc = "Add a tag (press any key)" },
# Fast Add tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --keys=!1q", desc = "Add tag(s) with fixed tag keys = (! and 1 and q)" },
# { on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --keys=*", desc = "Add tag with fixed tag key = *" },
# { on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --key=*", desc = "Add tag with fixed tag key = *" },
# Add tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input new tag key(s) to add to selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "a", "i" ], run = "plugin simple-tag -- add-tag --input", desc = "Add tag(s) with value from (input box)" },
#─────────────────────────── REMOVE/DELETE TAG(S) ───────────────────────────
# Remove a tag (press any tag key)
# A tag hint window will show up.
# Simply press any tag key to be removed from selected or hovered files/folders.
{ on = [ "t", "d", "k" ], run = "plugin simple-tag -- remove-tag", desc = "Remove a tag (press any key)" },
# Fast Remove tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --keys=!1q", desc = "Remove tag(s) with fixed tag keys = (! and 1 and q)" },
# { on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --keys=*", desc = "Remove tag with fixed tag key = *" },
# { on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --key=*", desc = "Remove tag with fixed tag key = *" },
# Remove tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input tag key(s) to be removed from selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "d", "i" ], run = "plugin simple-tag -- remove-tag --input", desc = "Remove tag(s) with value from (input box)" },
#─────────────────────────── REPLACE ALL OLD TAG(S) WITH NEW TAG(S) ───────────────────────────
# Replace a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key for selected or hovered files/folders.
{ on = [ "t", "r", "k" ], run = "plugin simple-tag -- replace-tag", desc = "Replace with a new tag (press any key)" },
# Fast Replace tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --keys=!1q", desc = "Replace tag(s) with fixed tag keys = (! and 1 and q)" },
# { on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --keys=*", desc = "Replace tag(s) with fixed tag key = *" },
# { on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --key=*", desc = "Replace tag(s) with fixed tag key = *" },
# Replace tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input new tag key(s) for selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "r", "i" ], run = "plugin simple-tag -- replace-tag --input", desc = "Replace tag(s) with value from (input box)" },
#─────────────────────────── EDIT TAG(S) ───────────────────────────
# Edit a tag for hovered or selected files/folders
# An input box with current tagged keys and a tag hint window will show up for each hovered or selected files/folders.
# Simply edit tag key(s) for selected or hovered files/folders.
# If you cancel any input box, all changes will be discarded.
{ on = [ "t", "e" ], run = "plugin simple-tag -- edit-tag ", desc = "Edit tag(s) (input box)" },
# ───────────────────────────── CLEAR TAG(S) ─────────────────────────────
# Clear all tags from selected or hovered files/folders
{ on = [ "t", "c" ], run = "plugin simple-tag -- clear", desc = "Clear all tags from selected or hovered files" },
# ───────────────────────────── CHANGE UI ─────────────────────────────
# Switch tag indicator between icon > tag key > hidden.
# Useful when u don't remember the tag key
{ on = [ "t", "u", "s" ], run = "plugin simple-tag -- toggle-ui", desc = "Toggle tag indicator (icon > tag key > hidden)" },
# Fixed tag indicator mode = hidden (Available modes: hidden|icon|text)
{ on = [ "t", "u", "h" ], run = "plugin simple-tag -- toggle-ui --mode=hidden", desc = "Hide all tags indicator" },
# ─────────────────────── FILTER FILES/FOLDERS BY TAGS: ───────────────────────
# Available filter modes:
# and → Filter files which contain all of selected tags (Default if mode isn't specified).
# or → Filter files which contain at least one of selected tags.
# NOTE: Not available in vfs mode (Remote Virtual Filesystem)
# Filter files/folders by tags
# Filter files/folders by a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key to filter files/folders containing that tag in current directory.
{ on = [ "t", "f" ], run = "plugin simple-tag -- filter", desc = "Filter files/folders by a tag (press any key)" },
# Fast Filter files/folders with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
# { on = [ "t", "f" ], run = "plugin simple-tag -- filter --key=!", desc = "Filter files/folders by a fixed tag = !" },
# { on = [ "t", "f" ], run = "plugin simple-tag -- filter --keys=!1q", desc = "Filter files/folders by multiple fixed tag(s) (! and 1 and q)" },
# Filter files/folders by tag(s) with value from input box.
# An input box and a tag hint window will show up.
# Simply input tag key(s) to filter files/folders of current directory.
# Do not input any delimiter.
# For example: Input value or --keys=!1q -> filter any files/folders contain all of these tags (! and 1 and q) in current directory.
{ on = [ "t", "F" ], run = "plugin simple-tag -- filter --input", desc = "Filter files/folders by tag(s) (input box)" },
# Filter files/folders by tag(s) with --mode=or.
# --mode=or -> Input value or --keys = !1q -> filter any files/folders contain at least one of these tags (! or 1 or q)
{ on = [ "t", "F" ], run = "plugin simple-tag -- filter --input --mode=or", desc = "Filter files/folders by contain tags (input box)" },
# { on = [ "t", "F" ], run = "plugin simple-tag -- filter --keys=!1q --mode=or", desc = "Filter files/folders by multiple fixed tag(s) (! or 1 or q)" },
# ─────────────────────── VISUAL SELECT FILES/FOLDERS BY TAGS: ───────────────────────
# Available selection actions:
# replace → Replaces the current selection list with files/folders that have the selected tag.
# unite → Combines the currently selected files/folders with those that have the selected tag.
# intersect → Keeps only the files/folders that are present in both the current selection and the tagged items.
# subtract → Deselects files/folders that have the selected tag from the current selection.
# exclude → Combines the currently selected files/folders with the tagged items, then deselects any overlapping items between the current selection and the tagged items.
# undo → Undos or redoes the last selection action.
# which_key will popup to choose selection mode
# And a tag hint window will show up.
# Simply select a selection mode then press any tag key to select files/folders
{ on = [ "t", "s", "t" ], run = "plugin simple-tag -- toggle-select", desc = "Select a selection action then select a tag key (toggle-select)" },
# fixed tag(s). --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q. They are the same.
{ on = [ "t", "s", "t" ], run = "plugin simple-tag -- toggle-select --keys=!1q", desc = "" },
# Run action on files/folders by a tag.
# A tag hint window will show up.
# Simply press any tag key to do the following action:
{ on = [ "t", "s", "r" ], run = "plugin simple-tag -- replace-select", desc = "replace-select" },
{ on = [ "t", "s", "u" ], run = "plugin simple-tag -- unite-select", desc = "unite-select" },
{ on = [ "t", "s", "i" ], run = "plugin simple-tag -- intersect-select", desc = "intersect-select" },
{ on = [ "t", "s", "s" ], run = "plugin simple-tag -- subtract-select", desc = "subtract-select" },
{ on = [ "t", "s", "e" ], run = "plugin simple-tag -- exclude-select", desc = "exclude-select" },
# Run action on files/folders by fixed tag(s). --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q. They are the same.
{ on = [ "t", "s", "e" ], run = "plugin simple-tag -- replace-select --keys=!1q", desc = "Replaces the current selection list with files/folders that have (! and 1 and q) tag(s)" },
# Run action on files/folders by tag(s) with value from input box.
# A tag hint window will show up.
# Simply input tag key(s) to do the following action:
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --input", desc = "replace-select --input" },
{ on = [ "t", "s", "U" ], run = "plugin simple-tag -- unite-select --input", desc = "unite-select --input" },
{ on = [ "t", "s", "I" ], run = "plugin simple-tag -- intersect-select --input", desc = "intersect-select --input" },
{ on = [ "t", "s", "S" ], run = "plugin simple-tag -- subtract-select --input", desc = "subtract-select --input" },
{ on = [ "t", "s", "E" ], run = "plugin simple-tag -- exclude-select --input", desc = "exclude-select --input" },
# it also support --mode=or when using with --input or --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --input --mode=or", desc = "replace-select --input --mode=or" },
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --keys=!1q --mode=or", desc = "replace-select --keys=!1q --mode=or" },
# Undo/Redo selection (only works after using 5 modes above)
{ on = [ "t", "s", "u" ], run = "plugin simple-tag -- undo-select", desc = "Undos/Redos the last selection action" },
# Directory navigation
{ on = ["k"], run = "arrow -1", desc = "Move cursor up" },
{ on = ["j"], run = "arrow 1", desc = "Move cursor down" },
{ on = ["h"], run = "leave", desc = "Go back to parent directory" },
{ on = ["l"], run = "enter", desc = "Enter directory" },
# File operations
{ on = ["<Enter>"], run = "open", desc = "Open selected files" },
{ on = ["y"], run = "yank", desc = "Yank selected files (copy)" },
{ on = ["x"], run = "yank --cut", desc = "Yank selected files (cut)" },
{ on = ["p"], run = "paste", desc = "Paste yanked files" },
{ on = ["d"], run = "remove", desc = "Trash selected files" },
{ on = ["D"], run = "remove --permanently", desc = "Permanently delete selected files" },
{ on = ["a"], run = "create", desc = "Create a file or directory" },
{ on = ["r"], run = "rename --cursor=before_ext", desc = "Rename selected file" },
# Selection
{ on = ["<Space>"], run = ["select --state=none", "arrow 1"], desc = "Toggle selection" },
{ on = ["v"], run = "visual_mode", desc = "Enter visual mode" },
{ on = ["V"], run = "visual_mode --unset", desc = "Enter visual mode (unset)" },
# Search
{ on = ["/"], run = "find --smart", desc = "Find file" },
{ on = ["n"], run = "find_arrow", desc = "Go to next found" },
{ on = ["N"], run = "find_arrow --previous", desc = "Go to previous found" },
# Tabs
{ on = ["T"], run = "tab_create --current", desc = "Create new tab" },
{ on = ["1"], run = "tab_switch 0", desc = "Switch to tab 1" },
{ on = ["2"], run = "tab_switch 1", desc = "Switch to tab 2" },
{ on = ["3"], run = "tab_switch 2", desc = "Switch to tab 3" },
# Preview
{ on = ["z"], run = "plugin --sync hide-preview", desc = "Toggle preview" },
# Other
{ on = ["g", "h"], run = "cd ~", desc = "Go to home directory" },
{ on = ["g", "c"], run = "cd ~/.config", desc = "Go to config directory" },
{ on = ["g", "d"], run = "cd ~/Downloads", desc = "Go to downloads" },
{ on = ["~"], run = "help", desc = "Open help" },
]
[tasks]
keymap = [
{ on = "<Esc>", run = "close", desc = "Close task manager" },
{ on = "<C-[>", run = "close", desc = "Close task manager" },
{ on = "<C-c>", run = "close", desc = "Close task manager" },
{ on = "w", run = "close", desc = "Close task manager" },
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Enter>", run = "inspect", desc = "Inspect the task" },
{ on = "x", run = "cancel", desc = "Cancel the task" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
prepend_keymap = [
{ on = ["<Esc>"], run = "close", desc = "Close task manager" },
{ on = ["k"], run = "arrow -1", desc = "Move cursor up" },
{ on = ["j"], run = "arrow 1", desc = "Move cursor down" },
]
[spot]
[select]
keymap = [
{ on = "<Esc>", run = "close", desc = "Close the spot" },
{ on = "<C-[>", run = "close", desc = "Close the spot" },
{ on = "<C-c>", run = "close", desc = "Close the spot" },
{ on = "<Tab>", run = "close", desc = "Close the spot" },
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "h", run = "swipe -1", desc = "Swipe to the next file" },
{ on = "l", run = "swipe 1", desc = "Swipe to the previous file" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Left>", run = "swipe -1", desc = "Swipe to the next file" },
{ on = "<Right>", run = "swipe 1", desc = "Swipe to the previous file" },
# Copy
{ on = [ "c", "c" ], run = "copy cell", desc = "Copy selected cell" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
]
[pick]
keymap = [
{ on = "<Esc>", run = "close", desc = "Cancel pick" },
{ on = "<C-[>", run = "close", desc = "Cancel pick" },
{ on = "<C-c>", run = "close", desc = "Cancel pick" },
{ on = "<Enter>", run = "close --submit", desc = "Submit the pick" },
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
prepend_keymap = [
{ on = ["<Esc>"], run = "close", desc = "Cancel selection" },
{ on = ["<Enter>"], run = "close --submit", desc = "Submit selection" },
{ on = ["k"], run = "arrow -1", desc = "Move cursor up" },
{ on = ["j"], run = "arrow 1", desc = "Move cursor down" },
]
[input]
keymap = [
{ on = "<C-c>", run = "close", desc = "Cancel input" },
{ on = "<Enter>", run = "close --submit", desc = "Submit input" },
{ on = "<Esc>", run = "escape", desc = "Go back the normal mode, or cancel input" },
{ on = "<C-[>", run = "escape", desc = "Go back the normal mode, or cancel input" },
# Mode
{ on = "i", run = "insert", desc = "Enter insert mode" },
{ on = "a", run = "insert --append", desc = "Enter append mode" },
{ on = "I", run = [ "move -999", "insert" ], desc = "Move to the BOL, and enter insert mode" },
{ on = "A", run = [ "move 999", "insert --append" ], desc = "Move to the EOL, and enter append mode" },
{ on = "v", run = "visual", desc = "Enter visual mode" },
{ on = "V", run = [ "move -999", "visual", "move 999" ], desc = "Enter visual mode and select all" },
# Character-wise movement
{ on = "h", run = "move -1", desc = "Move back a character" },
{ on = "l", run = "move 1", desc = "Move forward a character" },
{ on = "<Left>", run = "move -1", desc = "Move back a character" },
{ on = "<Right>", run = "move 1", desc = "Move forward a character" },
{ on = "<C-b>", run = "move -1", desc = "Move back a character" },
{ on = "<C-f>", run = "move 1", desc = "Move forward a character" },
# Word-wise movement
{ on = "b", run = "backward", desc = "Move back to the start of the current or previous word" },
{ on = "w", run = "forward", desc = "Move forward to the start of the next word" },
{ on = "e", run = "forward --end-of-word", desc = "Move forward to the end of the current or next word" },
{ on = "<A-b>", run = "backward", desc = "Move back to the start of the current or previous word" },
{ on = "<A-f>", run = "forward --end-of-word", desc = "Move forward to the end of the current or next word" },
# Line-wise movement
{ on = "0", run = "move -999", desc = "Move to the BOL" },
{ on = "$", run = "move 999", desc = "Move to the EOL" },
{ on = "<C-a>", run = "move -999", desc = "Move to the BOL" },
{ on = "<C-e>", run = "move 999", desc = "Move to the EOL" },
{ on = "<Home>", run = "move -999", desc = "Move to the BOL" },
{ on = "<End>", run = "move 999", desc = "Move to the EOL" },
# Delete
{ on = "<Backspace>", run = "backspace", desc = "Delete the character before the cursor" },
{ on = "<Delete>", run = "backspace --under", desc = "Delete the character under the cursor" },
{ on = "<C-h>", run = "backspace", desc = "Delete the character before the cursor" },
{ on = "<C-d>", run = "backspace --under", desc = "Delete the character under the cursor" },
# Kill
{ on = "<C-u>", run = "kill bol", desc = "Kill backwards to the BOL" },
{ on = "<C-k>", run = "kill eol", desc = "Kill forwards to the EOL" },
{ on = "<C-w>", run = "kill backward", desc = "Kill backwards to the start of the current word" },
{ on = "<A-d>", run = "kill forward", desc = "Kill forwards to the end of the current word" },
# Cut/Yank/Paste
{ on = "d", run = "delete --cut", desc = "Cut the selected characters" },
{ on = "D", run = [ "delete --cut", "move 999" ], desc = "Cut until the EOL" },
{ on = "c", run = "delete --cut --insert", desc = "Cut the selected characters, and enter insert mode" },
{ on = "C", run = [ "delete --cut --insert", "move 999" ], desc = "Cut until the EOL, and enter insert mode" },
{ on = "x", run = [ "delete --cut", "move 1 --in-operating" ], desc = "Cut the current character" },
{ on = "y", run = "yank", desc = "Copy the selected characters" },
{ on = "p", run = "paste", desc = "Paste the copied characters after the cursor" },
{ on = "P", run = "paste --before", desc = "Paste the copied characters before the cursor" },
# Undo/Redo
{ on = "u", run = "undo", desc = "Undo the last operation" },
{ on = "<C-r>", run = "redo", desc = "Redo the last operation" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
]
[confirm]
keymap = [
{ on = "<Esc>", run = "close", desc = "Cancel the confirm" },
{ on = "<C-[>", run = "close", desc = "Cancel the confirm" },
{ on = "<C-c>", run = "close", desc = "Cancel the confirm" },
{ on = "<Enter>", run = "close --submit", desc = "Submit the confirm" },
{ on = "n", run = "close", desc = "Cancel the confirm" },
{ on = "y", run = "close --submit", desc = "Submit the confirm" },
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
prepend_keymap = [
{ on = ["<Esc>"], run = "close", desc = "Cancel input" },
{ on = ["<Enter>"], run = "close --submit", desc = "Submit input" },
]
[completion]
keymap = [
{ on = "<C-c>", run = "close", desc = "Cancel completion" },
{ on = "<Tab>", run = "close --submit", desc = "Submit the completion" },
{ on = "<Enter>", run = [ "close --submit", "close_input --submit" ], desc = "Submit the completion and input" },
{ on = "<A-k>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<A-j>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
{ on = "<C-p>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<C-n>", run = "arrow 1", desc = "Move cursor down" },
# Help
{ on = "~", run = "help", desc = "Open help" },
{ on = "<F1>", run = "help", desc = "Open help" },
prepend_keymap = [
{ on = ["<Tab>"], run = "close --submit", desc = "Submit completion" },
{ on = ["k"], run = "arrow -1", desc = "Move cursor up" },
{ on = ["j"], run = "arrow 1", desc = "Move cursor down" },
]
[help]
keymap = [
{ on = "<Esc>", run = "escape", desc = "Clear the filter, or hide the help" },
{ on = "<C-[>", run = "escape", desc = "Clear the filter, or hide the help" },
{ on = "<C-c>", run = "close", desc = "Hide the help" },
# Navigation
{ on = "k", run = "arrow -1", desc = "Move cursor up" },
{ on = "j", run = "arrow 1", desc = "Move cursor down" },
{ on = "<Up>", run = "arrow -1", desc = "Move cursor up" },
{ on = "<Down>", run = "arrow 1", desc = "Move cursor down" },
# Filtering
{ on = "f", run = "filter", desc = "Apply a filter for the help items" },
prepend_keymap = [
{ on = ["<Esc>"], run = "escape", desc = "Clear filter or exit help" },
{ on = ["q"], run = "close", desc = "Exit help" },
{ on = ["k"], run = "arrow -1", desc = "Move cursor up" },
{ on = ["j"], run = "arrow 1", desc = "Move cursor down" },
]

View File

@@ -1,54 +1,87 @@
[[plugin.deps]]
use = "ahkohd/eza-preview"
rev = "5ef05bc"
hash = "72355a6c8b7c8de6ed4dda0f98f86fee"
use = "yazi-rs/plugins:smart-enter"
rev = "4e55902"
hash = "56fdabc96fc1f4d53c96eb884b02a5be"
[[plugin.deps]]
use = "iynaix/time-travel"
rev = "85baafd"
hash = "653fca8253e8cc431e7b1ceacc53ccfc"
use = "yazi-rs/plugins:jump-to-char"
rev = "4e55902"
hash = "ce67445ebb1bf3d97b8e44f50904b2c5"
[[plugin.deps]]
use = "AnirudhG07/rich-preview"
rev = "6752254"
hash = "c9a3d0731e7d7340e2c6d6126b1f3aa3"
[[plugin.deps]]
use = "yazi-rs/plugins:chmod"
rev = "02d18be"
hash = "4c7e8fd0266eedee7b619d966bd2d025"
[[plugin.deps]]
use = "Sonico98/exifaudio"
rev = "d794614"
hash = "a8e15d3c21c02a5af41d46ed04778a02"
[[plugin.deps]]
use = "dawsers/toggle-view"
rev = "9ae57f9"
hash = "9d291f6cecb1f1f5542fc18177d5c107"
[[plugin.deps]]
use = "llanosrocas/yaziline"
rev = "1342efe"
hash = "a84a339953a568fee1d8beb63e6dca73"
[[plugin.deps]]
use = "h-hg/yamb"
rev = "22af003"
hash = "7cc42012a7c2099f80064d228feb8d44"
[[plugin.deps]]
use = "Lil-Dank/lazygit"
rev = "7a08a09"
hash = "a1fa2b3e1826c3a34804ea8c548e9f80"
use = "yazi-rs/plugins:git"
rev = "4e55902"
hash = "36a484acf6a0a0219c543ccb4cee218f"
[[plugin.deps]]
use = "yazi-rs/plugins:mount"
rev = "5eea960"
hash = "b3f1d6ec3721d4061aad5f69cddb0cf9"
rev = "4e55902"
hash = "e2d4bfccf31e5ab05f46fee4797c5215"
[[flavor.deps]]
use = "yazi-rs/flavors:catppuccin-mocha"
rev = "fc8eeaa"
hash = "407710c2af9621a8351453e637d6c870"
[[plugin.deps]]
use = "yazi-rs/plugins:mime-ext"
rev = "4e55902"
hash = "48a77ab785d1ee73bc2d7bbe2a4c2090"
[[plugin.deps]]
use = "ndtoan96/ouch"
rev = "cfb9140"
hash = "b5067143415bd2d46c0dfa57319ddcef"
[[plugin.deps]]
use = "yazi-rs/plugins:piper"
rev = "4e55902"
hash = "2dd68af59418b631b9703a03f606b31f"
[[plugin.deps]]
use = "boydaihungst/mediainfo"
rev = "90a1652"
hash = "7a83bfab51d1d2ba6558cc56bd52539a"
[[plugin.deps]]
use = "AnirudhG07/rich-preview"
rev = "573b275"
hash = "c3e2871c9ef244fd181f203791f9b0d2"
[[plugin.deps]]
use = "stelcodes/bunny"
rev = "7137a44"
hash = "58bfa473bcac8574400e573787954512"
[[plugin.deps]]
use = "Lil-Dank/lazygit"
rev = "0e56060"
hash = "ab2e66065a94cca4886b303518e44bd8"
[[plugin.deps]]
use = "MasouShizuka/projects"
rev = "eed0657"
hash = "ca79de2b3bb2247906e01b2261e5d2bb"
[[plugin.deps]]
use = "XYenon/yafg"
rev = "6034c67"
hash = "11543279fd83ad4cacdfb07d67016928"
[[plugin.deps]]
use = "Shallow-Seek/fazif"
rev = "6e10488"
hash = "c549ff30fb1d1d97c734010fe82f6295"
[[plugin.deps]]
use = "GianniBYoung/rsync"
rev = "14d2828"
hash = "7394430ba473dce1023721622438bf3d"
[[plugin.deps]]
use = "Ape/simple-status"
rev = "d0da104"
hash = "68603fdd1dcaf415227e2c77a9317947"
[[plugin.deps]]
use = "llanosrocas/yaziline"
rev = "6266926"
hash = "9917ab5cb9bdbab7ca7f2501f84f0f11"
[flavor]
deps = []

Submodule yazi/.config/yazi/plugins/PPDATAyaziconfigpluginsfg.yazi deleted from c201a3e1c0

View File

@@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright © 2024 Stel Clementine
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.

View File

@@ -0,0 +1,102 @@
# bunny.yazi 🐰
*🩷 Hop around your filesystem 🩷*
This is a bookmark plugin for [yazi](https://github.com/sxyazi/yazi) which augments the builtin bookmarking abilities into a single menu of `cd` powers designed with user experience (and cuteness) in mind. Bookmarks are referred to as *hops* because users should always feel adorable while using their terminal.
## Features
- Create persistent hops in your `init.lua` config file
- Create ephemeral hops while using yazi
- Hop to any directory open in another tab
- Hop back to previous directory (history is associated with tab number)
- Hop by fuzzy searching available hops with [fzf](https://github.com/junegunn/fzf) or similar program
- Single menu for all functionality, therefore only one keymap is required in your `keymap.toml` file
- Hands off: no reads or writes to your filesystem, all state is kept in memory
<img src="https://i.imgur.com/9OKQJUT.png" alt="bunny.yazi menu open in a terminal"/>
## Installation
### With `git`
```sh
git clone https://github.com/stelcodes/bunny.yazi ~/.config/yazi/plugins/bunny.yazi
```
### With `yapack`
```sh
ya pack -a stelcodes/bunny
```
### With Nix (Home Manager + flakes)
`flake.nix`:
```nix
inputs = {
bunny-yazi = {
url = "github:stelcodes/bunny.yazi";
flake = false;
};
};
```
Home Manager config:
```nix
programs.yazi = {
plugins.bunny = "${inputs.bunny-yazi}";
initLua = ''
require("bunny"):setup({ ... })
'';
keymap.mgr.prepend_keymap = [
{ on = ";"; run = "plugin bunny"; desc = "Start bunny.yazi"; }
];
};
```
## Configuration
`~/.config/yazi/init.lua`:
```lua
require("bunny"):setup({
hops = {
{ key = "/", path = "/", },
{ key = "t", path = "/tmp", },
{ key = "n", path = "/nix/store", desc = "Nix store" },
{ key = "~", path = "~", desc = "Home" },
{ key = "m", path = "~/Music", desc = "Music" },
{ key = "d", path = "~/Desktop", desc = "Desktop" },
{ key = "D", path = "~/Documents", desc = "Documents" },
{ key = "c", path = "~/.config", desc = "Config files" },
{ key = { "l", "s" }, path = "~/.local/share", desc = "Local share" },
{ key = { "l", "b" }, path = "~/.local/bin", desc = "Local bin" },
{ key = { "l", "t" }, path = "~/.local/state", desc = "Local state" },
-- key and path attributes are required, desc is optional
},
desc_strategy = "path", -- If desc isn't present, use "path" or "filename", default is "path"
ephemeral = true, -- Enable ephemeral hops, default is true
tabs = true, -- Enable tab hops, default is true
notify = false, -- Notify after hopping, default is false
fuzzy_cmd = "fzf", -- Fuzzy searching command, default is "fzf"
})
```
`~/.config/yazi/keymap.toml`:
```toml
[[mgr.prepend_keymap]]
desc = "Start bunny.yazi"
on = ";"
run = "plugin bunny"
# Optionally, add another keymap to immediately fuzzy search bookmarks
[[mgr.prepend_keymap]]
desc = "Start bunny.yazi fuzzy search"
on = "'"
run = "plugin bunny fuzzy"
```
## Inspiration
[yamb.yazi](https://github.com/h-hg/yamb.yazi)
[nnn bookmarks](https://github.com/jarun/nnn/wiki/Basic-use-cases#add-bookmarks)

View File

@@ -0,0 +1,385 @@
--- @since 25.5.28
local function debug(...)
local function toReadableString(val)
if type(val) == "table" then
local str = "{ "
for k, v in pairs(val) do
str = str .. "[" .. tostring(k) .. "] = " .. toReadableString(v) .. ", "
end
return str .. "}"
elseif type(val) == "Url" then
return "Url:" .. tostring(val)
else
return tostring(val)
end
end
local args = { ... }
local processed_args = {}
for _, arg in pairs(args) do
table.insert(processed_args, toReadableString(arg))
end
ya.dbg("BUNNY.YAZI", table.unpack(processed_args))
end
local function fail(s, ...) ya.notify { title = "bunny.yazi", content = string.format(s, ...), timeout = 4, level = "error" } end
local function info(s, ...) ya.notify { title = "bunny.yazi", content = string.format(s, ...), timeout = 2, level = "info" } end
local get_state = ya.sync(function(state, attr)
return state[attr]
end)
local set_state = ya.sync(function(state, attr, value)
state[attr] = value
end)
local get_cwd = ya.sync(function(state)
return tostring(cx.active.current.cwd) -- Url objects are evil >.<"
end)
local get_current_tab_idx = ya.sync(function(state)
return cx.tabs.idx
end)
local get_tabs_as_paths = ya.sync(function(state)
local tabs = cx.tabs
local active_tab_idx = tabs.idx
local result = {}
for idx = 1, #tabs, 1 do
if idx ~= active_tab_idx and tabs[idx] then
result[idx] = tostring(tabs[idx].current.cwd)
end
end
return result
end)
local some = function(...)
for _, v in ipairs({ ... }) do
if v ~= nil then
return v
end
end
end
local function filename(pathstr)
if pathstr == "/" then return pathstr end
local url_name = Url(pathstr):name()
if url_name then
return tostring(url_name)
else
return pathstr
end
end
local function path_to_desc(path, strategy)
if strategy == "filename" then
return filename(path)
end
local home = os.getenv("HOME")
if home and home ~= "" then
local startPos, endPos = string.find(path, home)
-- Only substitute if the match is from the start of path, very important
if startPos == 1 then
return "~" .. path:sub(endPos + 1)
end
end
return tostring(path)
end
local function sort_hops(hops)
local function convert_key(key)
local t = type(key)
if t == "table" then
-- If table, sort by first key string
return key[1]
elseif t == "string" and string.lower(key) ~= key then
-- If uppercase letter (signifying an ephemeral hop), prepend "z"
-- so it gets sorted after lowercase persistent hops
return "z" .. key
end
return key
end
table.sort(hops, function(x, y)
return convert_key(x.key) < convert_key(y.key)
end)
return hops
end
local create_special_hops = function(config)
local hops = {}
local desc_strategy, tabs, ephemeral = config.desc_strategy, config.tabs, config.ephemeral
if ephemeral then
table.insert(hops, { key = "<Enter>", desc = "Create hop", path = "__MARK__" })
end
table.insert(hops, { key = "<Space>", desc = "Fuzzy search", path = "__FUZZY__" })
local tabhist = get_state("tabhist")
local tab = get_current_tab_idx()
if tabhist[tab] and tabhist[tab][2] then
local previous_dir = tabhist[tab][2]
table.insert(hops, {
key = "<Backspace>",
path = previous_dir,
desc = path_to_desc(previous_dir, desc_strategy)
})
end
if tabs then
for idx, tab_path in pairs(get_tabs_as_paths()) do
table.insert(hops, {
key = tostring(idx),
path = tab_path,
desc = path_to_desc(tab_path, desc_strategy)
})
end
end
return hops
end
local function validate_options(options)
local function validate_key(key)
local kt = type(key)
if not key then
return false, "key is missing"
elseif kt == "string" then
if utf8.len(key) ~= 1 then
return false, "key must be single character"
end
elseif kt == "table" then
if #key == 0 then
return false, "key cannot be empty table"
end
for _, char in pairs(key) do
if utf8.len(char) ~= 1 then
return false, "key list must contain single characters"
end
end
else
return false, "key must be string or table"
end
return true, ""
end
if type(options) ~= "table" then
return "Invalid config"
end
local hops, desc_strategy, tabs, ephemeral, fuzzy_cmd, notify =
options.hops, options.desc_strategy, options.tabs,
options.ephemeral, options.fuzzy_cmd, options.notify
-- Validate hops
if type(hops) == "table" then
local used_keys = {}
for idx, hop in pairs(hops) do
hop.desc = hop.desc or hop.tag or nil -- used to be tag, allow for backwards compat
local key_is_validated, key_err = validate_key(hop.key)
local err = 'Invalid "hops" config value: #' .. idx .. " "
if not key_is_validated then
return err .. key_err
elseif not hop.path then
return err .. 'path is missing'
elseif type(hop.path) ~= "string" or string.len(hop.path) == 0 then
return err .. 'path must be non-empty string'
elseif hop.desc and (type(hop.desc) ~= "string" or string.len(hop.path) == 0) then
return err .. 'desc must be non-empty string'
end
-- Check for duplicate keys
if used_keys[hop.key] then
return err .. 'needs unique key'
end
-- Insert hop keys as table keys to easily check for set membership
used_keys[hop.key] = true
end
else
return 'Invalid "hops" config value'
end
-- Validate other options
if desc_strategy ~= nil and desc_strategy ~= "path" and desc_strategy ~= "filename" then
return 'Invalid "desc_strategy" config value'
elseif tabs ~= nil and type(notify) ~= "boolean" then
return 'Invalid "tabs" config value'
elseif ephemeral ~= nil and type(notify) ~= "boolean" then
return 'Invalid "ephemeral" config value'
elseif fuzzy_cmd ~= nil and type(fuzzy_cmd) ~= "string" then
return 'Invalid "fuzzy_cmd" config value'
elseif notify ~= nil and type(notify) ~= "boolean" then
return 'Invalid "notify" config value'
end
end
-- https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/fzf.lua
-- https://github.com/sxyazi/yazi/blob/main/yazi-plugin/src/process/child.rs
-- Returns nil if fzf command failed or user exited with escape key
local select_fuzzy = function(hops, config)
local permit = ui.hide()
local child, spawn_err =
Command(config.fuzzy_cmd):stdin(Command.PIPED):stdout(Command.PIPED):stderr(Command.INHERIT):spawn()
if not child then
fail("Command `%s` failed with code %s. Do you have it installed?", config.fuzzy_cmd, spawn_err.code)
return
end
local fuzzy_entries = {}
for _, hop in pairs(hops) do
local existing_desc = fuzzy_entries[hop.path]
if not existing_desc or existing_desc == "" then
local fuzzy_desc = hop.desc
-- Avoid repeating path in description
if fuzzy_desc == hop.path then
fuzzy_desc = ""
end
fuzzy_entries[hop.path] = fuzzy_desc
end
end
-- Build fzf input string
local input_lines = {}
for entry_path, entry_desc in pairs(fuzzy_entries) do
local line = entry_desc .. string.rep(" ", 23 - #entry_desc) .. "\t" .. entry_path
table.insert(input_lines, line)
end
child:write_all(table.concat(input_lines, "\n"))
child:flush()
local output, output_err = child:wait_with_output()
permit:drop()
if not output.status.success then
if output.status.code ~= 130 then -- user pressed escape to quit
fail("Command `%s` failed with code %s", config.fuzzy_cmd, output_err.code)
end
return
end
-- Parse fzf output, remove right padded spaces from desc
local desc, path = string.match(output.stdout, "^(.-) *\t(.-)\n$")
if not desc or not path or path == "" then
fail("Failed to parse fuzzy searcher result")
return
end
if desc == "" then
desc = path_to_desc(path, config.desc_strategy)
end
return { desc = desc, path = path }
end
local cd = function(selected_hop, config)
local _, dir_list_err = fs.read_dir(Url(selected_hop.path), { limit = 1, resolve = true })
if dir_list_err then
fail("Invalid directory " .. path_to_desc(selected_hop.path))
return
end
-- Assuming that if I can fs.read_dir, then this will also succeed
ya.emit("cd", { selected_hop.path })
if config.notify then
info('Hopped to ' .. selected_hop.desc)
end
end
local attempt_hop = function(hops, config)
local cands = {}
for _, hop in pairs(create_special_hops(config)) do
table.insert(cands, { desc = hop.desc, on = hop.key, path = hop.path })
end
for _, hop in pairs(hops) do
table.insert(cands, { desc = hop.desc, on = hop.key, path = hop.path })
end
local hops_idx = ya.which { cands = cands }
if not hops_idx then return end
local selected_hop = cands[hops_idx]
-- Handle special hops
if selected_hop.path == "__MARK__" then
local mark_cands = {};
-- Ideally any unicode character would be supported, but yazi.which
-- requies a concrete list of candidates
local candidate_chars = {
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
'W', 'X', 'Y', 'Z', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')',
'-', '_', '=', '+', '[', '{', ']', '}', '\\', '|', ';', ':', "'", '"', ',', '<',
'.', '>', '/', '?', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
}
for _, char in pairs(candidate_chars) do
table.insert(mark_cands, { on = char })
end
info("Press a key to create new hop")
local char_idx = ya.which { cands = mark_cands, silent = true }
if char_idx ~= nil then
local selected_char = mark_cands[char_idx].on
local cwd = get_cwd()
table.insert(hops, { key = selected_char, path = cwd, desc = path_to_desc(cwd, config.desc_strategy) })
set_state("hops", sort_hops(hops))
end
return
elseif selected_hop.path == "__FUZZY__" then
local fuzzy_hop = select_fuzzy(hops, config)
if not fuzzy_hop then return end
selected_hop = fuzzy_hop
end
cd(selected_hop, config)
end
local function init()
local options = get_state("options")
local err = validate_options(options)
if err then
set_state("init_error", err)
fail(err)
return
end
-- Set default config values
local desc_strategy = options.desc_strategy or "path"
set_state("config", {
desc_strategy = desc_strategy,
fuzzy_cmd = some(options.fuzzy_cmd, "fzf"),
notify = some(options.notify, false),
ephemeral = some(options.ephemeral, true),
tabs = some(options.tabs, true),
})
-- Set hops after ensuring they all have a description
local hops = {}
for _, hop in pairs(options.hops) do
hop.desc = hop.desc or path_to_desc(hop.path, desc_strategy)
-- Manually replace ~ from users so we can make a valid Url later to check if dir exists
if string.sub(hop.path, 1, 1) == "~" then
hop.path = os.getenv("HOME") .. hop.path:sub(2)
end
table.insert(hops, hop)
end
set_state("hops", sort_hops(hops))
set_state("init", true)
end
return {
setup = function(state, options)
state.options = options
ps.sub("cd", function(body)
-- Note: This callback is sync and triggered at startup!
local tab = body.tab -- type number
-- Very important to turn this into a string because Url has ownership issues
-- when passed to standard utility functions >.<'
-- https://github.com/sxyazi/yazi/issues/2159
local cwd = tostring(cx.active.current.cwd)
-- Upon startup this will be nil so initialize if necessary
local tabhist = state.tabhist or {}
-- tabhist structure:{ <tab_index> = { <current_dir>, <previous_dir?> }, ... }
if not tabhist[tab] then
-- If fresh tab, initialize tab history table
tabhist[tab] = { cwd }
else
-- Otherwise, shift history table to the right and add cwd to the front
tabhist[tab] = { cwd, tabhist[tab][1] }
end
state.tabhist = tabhist
end)
end,
entry = function(self, job)
if not get_state("init") then
init()
end
local init_error = get_state("init_error")
if init_error then
fail(init_error)
return
end
local hops, config = get_state("hops"), get_state("config")
if job.args[1] == "fuzzy" then
local fuzzy_hop = select_fuzzy(hops, config)
if fuzzy_hop then
cd(fuzzy_hop, config)
end
else
attempt_hop(hops, config)
end
end,
}

View File

@@ -1,28 +0,0 @@
# chmod.yazi
Execute `chmod` on the selected files to change their mode. This plugin is only available on Unix platforms since it relies on [`chmod(2)`](https://man7.org/linux/man-pages/man2/chmod.2.html).
https://github.com/yazi-rs/plugins/assets/17523360/7aa3abc2-d057-498c-8473-a6282c59c464
## Installation
```sh
ya pack -a yazi-rs/plugins:chmod
```
## Usage
Add this to your `~/.config/yazi/keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = [ "c", "m" ]
run = "plugin chmod"
desc = "Chmod on selected files"
```
Make sure the <kbd>c</kbd> => <kbd>m</kbd> key is not used elsewhere.
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.

View File

@@ -1,39 +0,0 @@
local selected_or_hovered = ya.sync(function()
local tab, paths = cx.active, {}
for _, u in pairs(tab.selected) do
paths[#paths + 1] = tostring(u)
end
if #paths == 0 and tab.current.hovered then
paths[1] = tostring(tab.current.hovered.url)
end
return paths
end)
return {
entry = function()
ya.manager_emit("escape", { visual = true })
local urls = selected_or_hovered()
if #urls == 0 then
return ya.notify { title = "Chmod", content = "No file selected", level = "warn", timeout = 5 }
end
local value, event = ya.input {
title = "Chmod:",
position = { "top-center", y = 3, w = 40 },
}
if event ~= 1 then
return
end
local status, err = Command("chmod"):arg(value):arg(urls):spawn():wait()
if not status or not status.success then
ya.notify {
title = "Chmod",
content = string.format("Chmod on selected files failed, error: %s", status and status.code or err),
level = "error",
timeout = 5,
}
end
end,
}

View File

@@ -1,38 +0,0 @@
# 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.

View File

@@ -1,231 +0,0 @@
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") }
-- TODO)) Remove legacy method when v0.4 gets released
local function display_error_legacy()
local p = ui.Paragraph(job.area, { error }):wrap(ui.Paragraph.WRAP)
ya.preview_widgets(job, { p })
end
local function display_error()
local p = ui.Text(error):area(job.area):wrap(ui.Text.WRAP)
ya.preview_widgets(job, { p })
end
if pcall(display_error) then else pcall(display_error_legacy) end
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
-- TODO)) Remove legacy method when v0.4 gets released
local function display_metadata_legacy()
local p = ui.Paragraph(job.area, metadata):wrap(ui.Paragraph.WRAP)
ya.preview_widgets(job, { p })
end
local function display_metadata()
local p = ui.Text(metadata):area(job.area):wrap(ui.Text.WRAP)
ya.preview_widgets(job, { p })
end
if pcall(display_metadata) then else pcall(display_metadata_legacy) end
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) == 1 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 1
end
local mediainfo_template = 'General;"\
$if(%Track%,Title: %Track%,)\
$if(%Track/Sort%,Sort Title: %Track/Sort%,)\
$if(%Title/Sort%,Sort Title: %Title/Sort%,)\
$if(%TITLESORT%,Sort Title: %TITLESORT%,)\
$if(%Performer%,Artist: %Performer%,)\
$if(%Performer/Sort%,Sort Artist: %Performer/Sort%,)\
$if(%ARTISTSORT%,Sort Artist: %ARTISTSORT%,)\
$if(%Album%,Album: %Album%,)\
$if(%Album/Sort%,Sort Album: %Album/Sort%)\
$if(%ALBUMSORT%,Sort Album: %ALBUMSORT%)\
$if(%Album/Performer%,Album Artist: %Album/Performer%)\
$if(%Album/Performer/Sort%,Sort Album Artist: %Album/Performer/Sort%)\
$if(%Genre%,Genre: %Genre%)\
$if(%Track/Position%,Track Number: %Track/Position%)\
$if(%Recorded_Date%,Year: %Recorded_Date%)\
$if(%Duration/String%,Duration: %Duration/String%)\
$if(%BitRate/String%,Bitrate: %BitRate/String%)\
"\
Audio;"Sample Rate: %SamplingRate%\
Channels: %Channel(s)%"\
'
-- Write the mediainfo template file into yazi's cache dir
local cache_dir = GetPath(tostring(cache))
fs.write(Url(cache_dir.."mediainfo.txt"), mediainfo_template)
local output = Command("exiftool")
:arg({ "-b", "-CoverArt", "-Picture", tostring(job.file.url) })
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:output()
if not output then
return 0
end
return fs.write(cache, output.stdout) and 1 or 2
end
return M

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 sharklasers996
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.

View File

@@ -1,63 +0,0 @@
# eza-preview.yazi
[Yazi](https://github.com/sxyazi/yazi) plugin to preview directories using [eza](https://github.com/eza-community/eza), can be switched between list and tree modes.
List mode:
![list.png](list.png)
Tree mode:
![tree.png](tree.png)
## Requirements
- [yazi (0.4+) or nightly](https://github.com/sxyazi/yazi)
- [eza (0.20+)](https://github.com/eza-community/eza)
## Installation
### Linux/MacOS
```sh
ya pack -a ahkohd/eza-preview
```
## Usage
Add `eza-preview` to previewers in `yazi.toml`:
```toml
[[plugin.prepend_previewers]]
name = "*/"
run = "eza-preview"
```
Set key binding to switch between list and tree modes in `keymap.toml`:
```toml
[manager]
prepend_keymap = [
{ on = [ "E" ], run = "plugin eza-preview", desc = "Toggle tree/list dir preview" },
{ on = [ "-" ], run = "plugin eza-preview --args='--inc-level'", desc = "Increment tree level" },
{ on = [ "_" ], run = "plugin eza-preview --args='--dec-level'", desc = "Decrement tree level" },
{ on = [ "$" ], run = "plugin eza-preview --args='--toggle-follow-symlinks'", desc = "Toggle tree follow symlinks" },
]
```
List mode is the default, if you want to have tree mode instead when starting yazi - update `init.lua` with:
```lua
require("eza-preview"):setup({
-- Determines the directory depth level to tree preview (default: 3)
level = 3,
-- Whether to follow symlinks when previewing directories (default: false)
follow_symlinks = false
-- Whether to show target file info instead of symlink info (default: false)
dereference = false
})
-- Or use default settings with empty table
require("eza-preview"):setup({})
```

View File

@@ -1,157 +0,0 @@
local M = {}
local function fail(s, ...)
ya.notify({ title = "Eza Preview", content = string.format(s, ...), timeout = 5, level = "error" })
end
local toggle_view_mode = ya.sync(function(state, _)
if state.tree == nil then
state.tree = false
end
state.tree = not state.tree
end)
local is_tree_view_mode = ya.sync(function(state, _)
return state.tree
end)
local set_opts = ya.sync(function(state, opts)
if state.opts == nil then
state.opts = { level = 3, follow_symlinks = false, dereference = false }
end
for key, value in pairs(opts or {}) do
state.opts[key] = value
end
end)
local get_opts = ya.sync(function(state)
return state.opts
end)
local inc_level = ya.sync(function(state)
state.opts.level = state.opts.level + 1
end)
local dec_level = ya.sync(function(state)
if state.opts.level > 1 then
state.opts.level = state.opts.level - 1
end
end)
local toggle_follow_symlinks = ya.sync(function(state)
state.opts.follow_symlinks = not state.opts.follow_symlinks
end)
function M:setup(opts)
set_opts(opts)
toggle_view_mode()
end
function M:entry(job)
local arg = job.arg
if arg["inc_level"] ~= nil then
inc_level()
elseif arg["dec_level"] ~= nil then
dec_level()
elseif arg["toggle_follow_symlinks"] ~= nil then
toggle_follow_symlinks()
else
set_opts()
toggle_view_mode()
end
ya.manager_emit("seek", { 0 })
end
function M:peek(job)
local opts = get_opts()
local arg = {
"--all",
"--color=always",
"--icons=always",
"--group-directories-first",
"--no-quotes",
tostring(job.file.url),
}
if is_tree_view_mode() then
table.insert(arg, "--tree")
table.insert(arg, string.format("--level=%d", opts.level))
end
if opts then
if opts.follow_symlinks then
table.insert(arg, "--follow-symlinks")
end
if opts.dereference then
table.insert(arg, "--dereference")
end
end
local child = Command("eza"):arg(arg):stdout(Command.PIPED):stderr(Command.PIPED):spawn()
local limit = job.area.h
local lines = ""
local num_lines = 1
local num_skip = 0
local empty_output = false
repeat
local line, event = child:read_line()
if event == 1 then
fail(tostring(event))
elseif event ~= 0 then
break
end
if num_skip >= job.skip then
lines = lines .. line
num_lines = num_lines + 1
else
num_skip = num_skip + 1
end
until num_lines >= limit
if num_lines == 1 and not is_tree_view_mode() then
empty_output = true
elseif num_lines == 2 and is_tree_view_mode() then
empty_output = true
end
child:start_kill()
if job.skip > 0 and num_lines < limit then
ya.manager_emit("peek", {
tostring(math.max(0, job.skip - (limit - num_lines))),
only_if = tostring(job.file.url),
upper_bound = "",
})
elseif empty_output then
ya.preview_widgets(job, {
ui.Text({ ui.Line("No items") }):area(job.area):align(ui.Text.CENTER),
})
else
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
end
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.manager_emit("peek", {
math.max(0, cx.active.preview.skip + step),
only_if = tostring(job.file.url),
force = true,
})
end
end
return M

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Xianyi Lin
Copyright (c) 2025 Shallow-Seek
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -0,0 +1,183 @@
fazif allows you to search over selected items in Yazi with your configuration of search and fuzzy filter command.
You can config search command ([fd](https://github.com/sharkdp/fd), [rg](https://github.com/BurntSushi/ripgrep), [rga](https://github.com/phiresky/ripgrep-all), [ag](https://github.com/ggreer/the_silver_searcher), [astgrep](https://github.com/ast-grep/ast-grep) ...), fuzzy filter command ([fzf](https://github.com/junegunn/fzf), [fzy](https://github.com/jhawthorn/fzy), [zf](https://github.com/natecraddock/zf), [skim](https://github.com/lotabout/skim)), and options in a script and spawn all your scripts easily into yazi. Here are some use cases.
1. Search within the current working directory when none are selected.
For example, a simple directory jumper. Simply create a file in `~/.config/yazi/plugins/fazif.yazi` with one of the following, make it executable, and set a keybinding.
```
#!/usr/bin/env zsh
fd -H -t d|fzf
```
or
```
#!/usr/bin/env zsh
fd -H -t d|zf
```
or jump to a dir. outside CWD by applying your query to a upper dir. with a shortcut key.
```
#!/usr/bin/env zsh
fd -H -t d|fzf \
--bind 'ctrl-e:transform:echo "change-prompt(Home_Dir> )+reload(fd . ~ --hidden --type d)"' \
```
2. Search within selected files and directories
Example 1: to jump to some dir. in the selected folders, simply create a file in `~/.config/yazi/plugins/fazif.yazi` with one of the following, make it executable, and set a keybinding.
```
#!/usr/bin/env zsh
fd -H -t d "$@"|fzf
```
or
```
#!/usr/bin/env zsh
fd -H -t d "$@"|zf
```
Example 2: use `fazifrga` script to search for a pattern in selected PDFs and preview the matching pages that have the pattern with fzf.
3. Reveal the selected file or enter the selected directory in a new yazi tab; if multiple items are selected in fzf (using the `-multi` option in fzf), then show the selected items in the search result view.
For example, find relevant books using `faziffd` and reveal them in yazi's search result view, then use `fazifrga` to search for a pattern in these books.
4. show recent modified files.
```
#!/usr/bin/env zsh
fd -H -t f --changed-within 1d|fzf
```
## How It Works
This plugin acts as a bridge between Yazi and standalone scripts. The main.lua file serves as a generic wrapper that:
1. Passes the current working directory and selected files/directories from Yazi (`"$@"` in the script) to the script
2. Executes the specified script (passed as an argument in the keymap)
3. Send results in Yazi search pane if multiple selected or reveal/enter the selected item in a yazi new tab
## Installation
1. Install via ya:
```bash
ya pkg -a Shallow-Seek/fazif
```
or
```bash
git clone https://github.com/Shallow-Seek/fazif.yazi.git ~/.config/yazi/plugins/fazif.yazi
```
2. The 3 default scripts `faziffd`, `fazifrg`, and `fazifrga` provided are examples with features shown in the next section. The plugin still works with your scripts without them.
Simple put your script in `~/.config/yazi/plugins/fazif.yazi` and set a keybinding to use them. To make your script search on selected items, just add `"$@"` to the search command. Check `faziffd` to see that.
Also you need change your `rg` or `rga`'s delimiter to `U+00A0` by adding the option `--field-match-separator $'\u00a0'`
to your `rg` or `rga` commmand and `--delimiter $'\u00a0'` option to `fzf`. See the default `fazifrg` as an example.
but you can modify the following line in `main.lua` to use your prefered delimiter.
```lua
local file = line:find("\xC2\xA0") and line:sub(1, line:find("\xC2\xA0") - 1) or line
```
> UTF-8 encoding of `U+00A0` is `\xC2\xA0`
Make sure your scripts are executable:
```bash
chmod +x ~/.config/yazi/plugins/fazif.yazi/faziffd
chmod +x ~/.config/yazi/plugins/fazif.yazi/fazifrg
chmod +x ~/.config/yazi/plugins/fazif.yazi/fazifrga
chmod +x ~/.config/yazi/plugins/fazif.yazi/yourscript1
...
```
You may need to update the shebang (`#!`) in the example scripts.
## Add Keymaps to Your Script
The plugin can be configured to run any of your scripts by passing the script name as an argument. Add the following to your `~/.config/yazi/keymap.toml` to bind each script to a key combination:
### Setting up all scripts:
```toml
# File/Directory finder using fd + fzf
[[mgr.prepend_keymap]]
on = [ "b", "d" ]
run = "plugin fazif faziffd"
desc = "Find files/directories with fd and fzf"
# Content finder using ripgrep + fzf
[[mgr.prepend_keymap]]
on = [ "b", "r" ]
run = "plugin fazif fazifrg"
desc = "Find content in files with ripgrep and fzf"
# Document content finder using ripgrep-all + fzf
[[mgr.prepend_keymap]]
on = [ "b", "a" ]
run = "plugin fazif fazifrga"
desc = "Find content in documents with ripgrep-all and fzf"
...
```
That's it. is not the default `:`, you will need to change the delimiter in main.lua.
---
## Example scripts
Read this section if you use the default scripts `faziffd`, `fazifrg`, and `fazifrga`.
### Features
1. **faziffd** - File/directory jumper using `fd`. Txt preview with `bat` and Directory preview with `eza`
2. **fazifrg** - `ripgrep` on selected. Preview shows file content with `bat` when started with no input. With any input, `rg` kicks in, and the preview highlights the matching line.
3. **fazifrga** - `ripgrep-all` search in selected PDFs and DjVu. Preview shows the first page of a document when started with no input. With any input, `rga` kicks in, and the preview shows the matching page in the document.
The 3 scripts use the following tools:
- [fzf](https://github.com/junegunn/fzf)
- [fd](https://github.com/sharkdp/fd) - Used by `faziffd`
- [ripgrep](https://github.com/BurntSushi/ripgrep) - Used by `fazifrg`
- [ripgrep-all](https://github.com/phiresky/ripgrep-all) - Used by `fazifrga`
- [rga djvu adaptor](https://github.com/phiresky/ripgrep-all/discussions/166) - Used by `fazifrga` to search in djvu
- Additional tools for document previews:
- [kitty](https://sw.kovidgoyal.net/kitty/) Image preview uses kitty icat. You can also use other terminals that support image or use ueberzugpp.
- [bat](https://github.com/sharkdp/bat) - Used by `faziffd`, `fazifrg`
- [eza](https://github.com/eza-community/eza) - Used by `faziffd`
- `pdftoppm` from [poppler-utils](https://github.com/freedesktop/poppler) - Used by `faziffd`, `fazifrga` for pdf prevew.
- `ddjvu` from [djvulibre](https://github.com/DjVuLibre/djvulibre) - Used by `faziffd`, `fazifrga` for djvu preview.
- [libreoffice](https://github.com/LibreOffice/core) for office documents - Used by `faziffd` for office file preview.
### Usage
#### faziffd - File/Directory jumper
- `Ctrl-w`: Search files in the home directory
- `Ctrl-e`: Search directories in the home directory
- `Alt-c`: Search directories in the current working directory
- `Ctrl-t`: Search files in the current working directory
- `Ctrl-f`: Search directories from the root
- `Ctrl-p`: Toggle the preview window/position
- `Ctrl-x`: Open in Yazi (new instance)(if `setsid` is not available, use `nohup`)
#### fazifrg, fazifrga
- `Ctrl-y`: Switch between rga search mode and fzf filtering mode
- `Ctrl-p`: Toggle the preview window/position
- `Ctrl-o`: `fazifrg` open file in Neovim at the matched line. `fazifrga` open document in Zathura at the matched page and highlight the query.
## License
This plugin is released under the MIT License.
## Acknowledgement
Plugin is based on the default [Yazi](https://github.com/sxyazi/yazi) fzf plugin and vcs-files plugin. Fzf scripts grow out of [fzf](https://github.com/junegunn/fzf)'s wiki and examples.

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env zsh
fd . -H "$@" |fzf \
--info=inline \
--multi \
--layout=reverse \
--prompt='ctl-wetcrfp_CWD> ' \
--bind 'ctrl-w:transform:echo "change-prompt(ctl-wetcrfp_Home_File> )+reload(fd . ~ --hidden --type f)"' \
--bind 'ctrl-e:transform:echo "change-prompt(ctl-wetcrfp_Home_Dir> )+reload(fd . ~ --hidden --type d)"' \
--bind 'alt-c:transform:echo "change-prompt(ctl-wetcrfp_CWD_Dir> )+reload(fd --hidden --type d)"' \
--bind 'ctrl-t:transform:echo "change-prompt(ctl-wetcrfp_CWD_File> )+reload(fd --hidden --type f)"' \
--bind 'ctrl-f:transform:echo "change-prompt(ctl-wetcrfp_root_Dir> )+reload(fd . / --hidden --type d)"' \
--bind 'ctrl-r:transform:echo "change-prompt(ctl-wetcrfp_Root_File> )+reload(fd . / --hidden --type f)"' \
--bind 'focus:transform-preview-label:echo {}' \
--bind 'ctrl-p:change-preview-window(right|down|hidden)' \
--bind 'focus:transform-preview-label:echo {}' \
--bind 'ctrl-o:execute-silent(xdg-open-nvim {} &)' \
--preview-window 'hidden' \
--preview '
printf "\033_Ga=d,q=1\033\\"
[ -d {} ] && eza -aTL 2 --group-directories-first --color=always --icons=always {} ||
tmp="/tmp/fzf_preview"
case $(basename {}) in
*.pdf)
pdftoppm -q -f 1 -l 1 -jpeg -jpegopt quality=60 -scale-to-x 1000 -scale-to-y -1 -singlefile {} $tmp && \
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp.jpg
;;
*.doc|*.docx|*.xls|*.xlsx|*.ppt|*.pptx|*.odt|*.ods|*.odp)
libreoffice --convert-to jpg --outdir /tmp {} >/dev/null 2>&1
mv "/tmp/${$(basename {})%.*}.jpg" $tmp
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp
;;
*.djvu)
ddjvu -format=ppm -page=1 -size 1000x-1 -aspect=yes {} $tmp 2>/dev/null && \
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp
;;
*)
if file --mime-type {} | grep -qP "image/(?!vnd\.djvu)"; then
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {}
else
bat -p {} --color=always 2>/dev/null
fi
;;
esac
'

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env sh
FD_COMMAND5="fd --changed-within 5d"
FD_COMMAND1="fd --changed-within 1d"
$FD_COMMAND5 -t f . "$@" |fzf \
--info=inline \
--multi \
--layout=reverse \
--prompt='ctl-wetcrfp_CWD5d> ' \
--bind "ctrl-w:transform:echo 'change-prompt(ctl-wetcrfp_HOME5d> )+reload($FD_COMMAND5 -t f . ~ )'" \
--bind "ctrl-e:transform:echo 'change-prompt(ctl-wetcrfp_HOME1d)+reload($FD_COMMAND1 -t f . ~)'" \
--bind "ctrl-t:transform:echo 'change-prompt(ctl-wetcrfp_CWD5d> )+reload($FD_COMMAND5 -t f)'" \
--bind "alt-c:transform:echo 'change-prompt(ctl-wetcrfp_CWD1d> )+reload($FD_COMMAND1 -t f)'" \
--bind "ctrl-r:transform:echo 'change-prompt(ctl-wetcrfp_HOMEA> )+reload($FD_COMMAND5 . ~)'" \
--bind "ctrl-f:transform:echo 'change-prompt(ctl-wetcrfp_HOMEA_WithH> )+reload($FD_COMMAND1 -H . ~)'" \
--bind 'focus:transform-preview-label:echo {}' \
--bind 'ctrl-p:change-preview-window(right|down|hidden)' \
--bind 'focus:transform-preview-label:echo {}' \
--bind 'ctrl-x:execute-silent(setsid kitty nnn {} &)' \
--bind 'ctrl-a:execute-silent(setsid kitty yazi {} &)' \
--bind 'ctrl-s:execute-silent(setsid thunar {} &)' \
--preview-window 'hidden' \
--preview '
printf "\033_Ga=d,q=1\033\\"
[ -d {} ] && eza -aTL 2 --group-directories-first --color=always --icons=always {} ||
tmp="/tmp/fzf_preview"
case $(basename {}) in
*.pdf)
pdftoppm -q -f 1 -l 1 -jpeg -jpegopt quality=60 -scale-to-x 1000 -scale-to-y -1 -singlefile {} $tmp && \
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp.jpg
;;
*.doc|*.docx|*.xls|*.xlsx|*.ppt|*.pptx|*.odt|*.ods|*.odp)
libreoffice --convert-to jpg --outdir /tmp {} >/dev/null 2>&1
mv "/tmp/${$(basename {})%.*}.jpg" $tmp
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp
;;
*.djvu)
ddjvu -format=ppm -page=1 -size 1000x-1 -aspect=yes {} $tmp 2>/dev/null && \
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp
;;
*)
if file --mime-type {} | grep -qP "image/(?!vnd\.djvu)"; then
kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 {}
else
bat -p {} --color=always 2>/dev/null
fi
;;
esac
'

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env zsh
rm -f /tmp/rg-fzf-{r,f} 2>/dev/null
RG_PREFIX="rg --with-filename --column --line-number --color=always --smart-case --field-match-separator $'\u00a0'"
FILES_TO_ADD=""
for item in "$@"; do
if [ -f "$item" ]; then
FILES_TO_ADD="$FILES_TO_ADD$item"$'\n'
fi
done
(fd . -H -t f "$@" 2>/dev/null & printf "%s" "$FILES_TO_ADD") | fzf \
--ansi \
--delimiter $'\u00a0' \
--disabled \
--prompt '1. ripgrep> ' \
--header 'CTRL-Y: Switch between ripgrep/fzf' \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} $([ $# -gt 0 ] && printf "%q " "$@") || true" \
--bind 'ctrl-y:transform:[[ ! $FZF_PROMPT =~ ripgrep ]] &&
echo "rebind(change)+change-prompt(1. ripgrep> )+disable-search+transform-query:echo \{q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r" ||
echo "unbind(change)+change-prompt(2. fzf> )+enable-search+transform-query:echo \{q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f"' \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--preview '[ -n "{2}" ] && bat --color=always {1} --style=numbers --highlight-line {2} || bat --color=always {} --style=numbers' \
--preview-window 'down,60%,+{2}+3/3,~3' \
--bind 'ctrl-p:change-preview-window(right,60%|hidden|down,60%)' \
--bind 'focus:transform-preview-label:echo $(basename {1})' \
--bind 'ctrl-o:execute(kitty -1 sh -c "nvim {1} +{2}" & )' \
--bind 'ctrl-x:execute-silent(setsid kitty -1 nnn {1} &)' \
--bind 'ctrl-a:execute-silent(setsid kitty -1 yazi {1} &)' \
--bind 'ctrl-s:execute-silent(setsid thunar {1} &)' \
--color 'label:117:bold'

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env zsh
rm -f /tmp/rg-fzf-{r,f} 2>/dev/null
RG_PREFIX="rga --glob='*.pdf' --glob='*.djvu' --glob='*.djv' --with-filename --color=always --no-heading --smart-case --field-match-separator $'\u00a0'"
FILES_TO_ADD=""
for item in "$@"; do
if [ -f "$item" ]; then
FILES_TO_ADD="$FILES_TO_ADD$item"$'\n'
fi
done
(fd . -e pdf -e djvu -e djv "$@" 2>/dev/null & printf "%s" "$FILES_TO_ADD") | fzf \
--ansi \
--delimiter $'\u00a0' \
--disabled \
--with-nth 2,1 \
--prompt="rga> " \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} $([ $# -gt 0 ] && printf "%q " "$@") || true" \
--bind 'focus:transform-preview-label:echo $(basename {1})' \
--bind 'ctrl-p:change-preview-window(right,50%|hidden,50%|down)' \
--bind 'ctrl-x:execute-silent(setsid kitty -1 nnn {1} &)' \
--bind 'ctrl-a:execute-silent(setsid kitty -1 yazi {1} &)' \
--bind 'ctrl-s:execute-silent(setsid thunar {1} &)' \
--preview-window 'down' \
--bind 'ctrl-y:transform:[[ ! $FZF_PROMPT =~ rga ]] &&
echo "rebind(change)+change-prompt(rga> )+disable-search+transform-query:echo \{q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r" ||
echo "unbind(change)+change-prompt(fzf> )+enable-search+transform-query:echo \{q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f"' \
--bind 'ctrl-o:execute(
page_info={2}
pagenumber=${page_info#Page }
pagenumber=${pagenumber%%: *}
context=${page_info#*: }
setsid zathura --page=$pagenumber --find=$context {1} &)' \
--preview '
printf "\033_Ga=d,q=1\033\\"
[ -n {2} ] && pagenumber=$(echo {2} | cut -d: -f1 | sed "s/Page\ //") || pagenumber=1
tmp="/tmp/fzf_preview"
case {1} in
*.pdf)
pdftoppm -q -f $pagenumber -l $pagenumber -jpeg -jpegopt quality=60 -scale-to-x 800 -scale-to-y -1 -singlefile {1} $tmp \
&& kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp.jpg
;;
*.djvu)
ddjvu -format=ppm -page=$pagenumber -size=800x-1 -aspect=yes {1} $tmp 2>/dev/null \
&& kitty icat --transfer-mode=memory --stdin=no --place=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}@0x0 $tmp
;;
esac
' \
# --bind "start:reload:$RG_PREFIX {q} || true" \

View File

@@ -0,0 +1,107 @@
local state = ya.sync(function()
local selected = {}
for _, url in pairs(cx.active.selected) do
selected[#selected + 1] = url
end
return cx.active.current.cwd, selected
end)
local function split_urls(cwd, output)
if not output or output == "" then return {} end
local t = {}
for line in output:gmatch("[^\r\n]+") do
if line ~= "" then
-- Get everything before first colon, or entire line if no colon
local file = line:find("\xC2\xA0") and line:sub(1, line:find("\xC2\xA0") - 1) or line
if file and file ~= "" then
local u = Url(file)
if u.is_absolute then
t[#t + 1] = u
else
t[#t + 1] = cwd:join(u)
end
end
end
end
return t
end
local function run_with(cwd, selected, script_name)
local script_path = os.getenv("HOME") .. "/.config/yazi/plugins/fazif.yazi/" .. script_name
local sepaths = {}
if #selected > 0 then
for _, u in ipairs(selected) do
table.insert(sepaths, tostring(u))
end
end
local child
if #selected == 0 then
child = Command(script_path):cwd(tostring(cwd)):stdin(Command.INHERIT):stdout(Command.PIPED):spawn()
else
child = Command(script_path):arg(sepaths):stdout(Command.PIPED):spawn()
end
if not child then
return nil, "Failed to start script"
end
local output, err = child:wait_with_output()
if not output then
return nil, "Cannot read output: " .. tostring(err)
elseif not output.status.success and output.status.code ~= 130 then
return nil, "Script exited with code " .. tostring(output.status.code)
end
return output.stdout, nil
end
local function entry(_, job)
local script_name = job.args[1]
local permit = ui.hide()
local cwd, selected = state()
local output, err = run_with(cwd, selected, script_name)
if permit then
permit:drop()
end
if not output then
return ya.notify { title = "Fazif", content = tostring(err), timeout = 5, level = "error" }
end
local urls = split_urls(cwd, output)
if #urls == 0 then
return
elseif #urls == 1 then
ya.emit("tab_create", {})
ya.emit(fs.cha(urls[1]).is_dir and "cd" or "reveal", { urls[1], raw = true })
else
ya.emit("tab_create", {})
local id = ya.id("ft")
local virtual_cwd = cwd:into_search("FZF Results")
ya.emit("cd", { Url(virtual_cwd) })
ya.emit("update_files", { op = fs.op("part", { id = id, url = Url(virtual_cwd), files = {} }) })
local files = {}
for i = 1, #urls do
local url = urls[i]
local cha = fs.cha(url, true)
if cha then
files[#files + 1] = File { url = url, cha = cha }
else
files[#files + 1] = File { url = url }
end
end
ya.emit("update_files", { op = fs.op("part", { id = id, url = Url(virtual_cwd), files = files }) })
ya.emit("update_files", { op = fs.op("done", { id = id, url = virtual_cwd, cha = Cha { kind = 16 } }) })
end
end
return { entry = entry }

Submodule yazi/.config/yazi/plugins/fg.yazi deleted from c201a3e1c0

View File

@@ -1 +0,0 @@
../LICENSE

View File

@@ -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.

View File

@@ -22,19 +22,19 @@ And register it as fetchers in your `~/.config/yazi/yazi.toml`:
```toml
[[plugin.prepend_fetchers]]
id = "git"
name = "*"
run = "git"
id = "git"
url = "*"
run = "git"
[[plugin.prepend_fetchers]]
id = "git"
name = "*/"
run = "git"
id = "git"
url = "*/"
run = "git"
```
## Advanced
> [!NOTE]
> [!NOTE]
> The following configuration must be put before `require("git"):setup()`
You can customize the [Style](https://yazi-rs.github.io/docs/plugins/layout#style) of the status sign with:

View File

@@ -1,4 +1,4 @@
--- @since 25.5.31
--- @since 25.12.29
local WINDOWS = ya.target_family() == "windows"
@@ -125,12 +125,7 @@ local add = ya.sync(function(st, cwd, repo, changed)
st.repos[repo][path] = code
end
end
-- TODO: remove this
if ui.render then
ui.render()
else
ya.render()
end
ui.render()
end)
---@param cwd string
@@ -142,12 +137,7 @@ local remove = ya.sync(function(st, cwd)
return
end
-- TODO: remove this
if ui.render then
ui.render()
else
ya.render()
end
ui.render()
st.dirs[cwd] = nil
if not st.repos[repo] then
return
@@ -180,15 +170,19 @@ local function setup(st, opts)
[CODES.updated] = t.updated and ui.Style(t.updated) or ui.Style():fg("yellow"),
}
local signs = {
[CODES.ignored] = t.ignored_sign or "",
[CODES.untracked] = t.untracked_sign or "?",
[CODES.modified] = t.modified_sign or "",
[CODES.added] = t.added_sign or "",
[CODES.deleted] = t.deleted_sign or "",
[CODES.updated] = t.updated_sign or "",
[CODES.ignored] = t.ignored_sign or " ",
[CODES.untracked] = t.untracked_sign or "? ",
[CODES.modified] = t.modified_sign or " ",
[CODES.added] = t.added_sign or " ",
[CODES.deleted] = t.deleted_sign or " ",
[CODES.updated] = t.updated_sign or " ",
}
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

View File

@@ -0,0 +1,28 @@
# jump-to-char.yazi
Vim-like `f<char>`, jump to the next file whose name starts with `<char>`.
https://github.com/yazi-rs/plugins/assets/17523360/aac9341c-b416-4e0c-aaba-889d48389869
## Installation
```sh
ya pkg add yazi-rs/plugins:jump-to-char
```
## Usage
Add this to your `~/.config/yazi/keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = "f"
run = "plugin jump-to-char"
desc = "Jump to char"
```
Note that, the keybindings above are just examples, please tune them up as needed to ensure they don't conflict with your other commands/plugins.
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.

View File

@@ -0,0 +1,32 @@
--- @since 25.5.31
local AVAILABLE_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
local changed = ya.sync(function(st, new)
local b = st.last ~= new
st.last = new
return b or not cx.active.finder
end)
local escape = function(s) return s == "." and "\\." or s end
return {
entry = function()
local cands = {}
for i = 1, #AVAILABLE_CHARS do
cands[#cands + 1] = { on = AVAILABLE_CHARS:sub(i, i) }
end
local idx = ya.which { cands = cands, silent = true }
if not idx then
return
end
local kw = escape(cands[idx].on)
if changed(kw) then
ya.emit("find_do", { "^" .. kw })
else
ya.emit("find_arrow", {})
end
end,
}

View File

@@ -4,9 +4,9 @@ Plugin for [Yazi](https://github.com/sxyazi/yazi) to manage git repos with [lazy
Make sure [lazygit](https://github.com/jesseduffield/lazygit) is installed and in your `PATH`.
## Installation
### Using `ya pack`
### Using `ya pkg`
```
ya pack -a Lil-Dank/lazygit
ya pkg add Lil-Dank/lazygit
```
### Manual
@@ -21,9 +21,11 @@ git clone https://github.com/Lil-Dank/lazygit.yazi.git %AppData%\yazi\config\plu
## Configuration
add this to your **keymap.toml** file
```toml
[[manager.prepend_keymap]]
[[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**

View File

@@ -9,8 +9,11 @@ return {
timeout = 5,
})
else
permit = ya.hide()
local output, err_code = Command("lazygit"):stderr(Command.PIPED):output()
permit = ui.hide and ui.hide() or ya.hide()
local output, err_code = Command("lazygit"):stdin(Command.INHERIT):stdout(Command.INHERIT):stderr(Command.PIPED):spawn()
if output and not err_code then
output, err_code = output:wait_with_output()
end
if err_code ~= nil then
ya.notify({
title = "Failed to run lazygit command",

View File

@@ -0,0 +1,19 @@
Copyright (c) 2024 Lauri Niskanen
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.

View File

@@ -0,0 +1,135 @@
# mediainfo.yazi (fork)
<!--toc:start-->
- [mediainfo.yazi (fork)](#mediainfoyazi-fork)
- [Preview](#preview)
- [Installation](#installation)
- [Configuration:](#configuration)
- [Custom theme](#custom-theme)
<!--toc:end-->
This is a Yazi plugin for previewing media files. The preview shows thumbnail
using `ffmpeg` if available and media metadata using `mediainfo`.
> [!IMPORTANT]
> Minimum version: yazi v25.5.31.
## Preview
- Video
![video](assets/2025-02-15-09-15-39.png)
- Audio file with cover
![audio_with_cover_picture](assets/2025-02-15-09-14-23.png)
- Images
![image](assets/2025-02-15-16-52-39.png)
- Subtitle
![subrip](assets/2025-02-15-16-51-11.png)
- SVG+XML file doesn't have useful information, so it only show the image preview.
- There are more file extensions which are supported by mediainfo. Just add file's MIME type to `prepend_previewers`, `prepend_preloaders`.
Use `spotter` to determine File's MIME type. [Default is `<Tab>` key](https://github.com/sxyazi/yazi/blob/1a6abae974370702c8865459344bf256de58359e/yazi-config/preset/keymap-default.toml#L59)
## Installation
- Install mediainfo CLI:
- [https://mediaarea.net/en/MediaInfo/Download](https://mediaarea.net/en/MediaInfo/Download)
- Run this command in terminal to check if it's installed correctly:
```bash
mediainfo --version
```
If it output `Not found` then add it to your PATH environment variable. It's better to ask ChatGPT to help you (Prompt: `Add MediaInfo CLI to PATH environment variable in Windows`).
- Install ImageMagick (for linux, you can use your distro package manager to install):
https://imagemagick.org/script/download.php
- Install this plugin:
```bash
ya pkg add boydaihungst/mediainfo
```
## Configuration:
> [!IMPORTANT]
>
> `mediainfo` use built-in video, image, svg, magick plugins behind the scene to render preview image, song cover.
> So you can remove those 4 plugins from `prepend_preloaders` and `prepend_previewers` sections in `yazi.toml`.
If you have cache problem, run this cmd, and follow the tips: `yazi --clear-cache`
Config folder for each OS: https://yazi-rs.github.io/docs/configuration/overview.
Create `.../yazi/yazi.toml` and add:
> [!IMPORTANT]
>
> For yazi (>=v25.12.29) replace `name` with `url`
```toml
[plugin]
prepend_preloaders = [
# Replace magick, image, video with mediainfo
{ mime = "{audio,video,image}/*", run = "mediainfo" },
{ mime = "application/subrip", run = "mediainfo" },
# Adobe Illustrator, Adobe Photoshop is image/adobe.photoshop, already handled above
{ mime = "application/postscript", run = "mediainfo" },
]
prepend_previewers = [
# Replace magick, image, video with mediainfo
{ mime = "{audio,video,image}/*", run = "mediainfo"},
{ mime = "application/subrip", run = "mediainfo" },
# Adobe Illustrator, Adobe Photoshop is image/adobe.photoshop, already handled above
{ mime = "application/postscript", run = "mediainfo" },
]
# There are more extensions which are supported by mediainfo.
# Just add file's MIME type to `previewers`, `preloaders` above.
# https://mediaarea.net/en/MediaInfo/Support/Formats
# For a large file like Adobe Illustrator, Adobe Photoshop, etc
# you may need to increase the memory limit if no image is rendered.
# https://yazi-rs.github.io/docs/configuration/yazi#tasks
[tasks]
image_alloc = 1073741824 # = 1024*1024*1024 = 1024MB
```
## Custom theme
Using the same style with spotter. [Read more](https://github.com/sxyazi/yazi/pull/2391)
Edit or add `yazi/theme.toml`:
```toml
[spot]
# Section header style.
# Example: Video, Text, Image,... with green color in preview images above
title = { fg = "green" }
# Value style.
# Example: `Format: FLAC` with blue color in preview images above
tbl_col = { fg = "blue" }
```
## (Optional) Keymaps to hide metadata and to preview images in full screen
> [!IMPORTANT]
> Use any key you want, but make sure there is no conflicts with [default Keybindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml).
Since Yazi prioritizes the first matching key, `prepend_keymap` takes precedence over defaults.
Or you can use `keymap` to replace all other keys
```toml
[mgr]
prepend_keymap = [
{ on = "<F9>", run = "plugin mediainfo -- toggle-metadata", desc = "Toggle media preview metadata" },
]
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 186 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 KiB

View File

@@ -0,0 +1,498 @@
--- @since 25.5.31
local skip_labels = {
["Complete name"] = true,
["CompleteName_Last"] = true,
["Unique ID"] = true,
["File size"] = true,
["Format/Info"] = true,
["Codec ID/Info"] = true,
["MD5 of the unencoded content"] = true,
}
local ENTRY_ACTION = {
toggle_metadata = "toggle-metadata",
}
local STATE_KEY = {
units = "units",
hide_metadata = "hide_metadata",
prev_metadata_area = "prev_metadata_area",
prev_peek_data = "prev_peek_data",
}
local magick_image_mimes = {
avif = true,
hei = true,
heic = true,
heif = true,
["heif-sequence"] = true,
["heic-sequence"] = true,
jxl = true,
xml = true,
["svg+xml"] = true,
["canon-cr2"] = true,
}
local seekable_mimes = {
["application/postscript"] = true,
["image/adobe.photoshop"] = true,
}
local M = {}
local suffix = "_mediainfo"
local SHELL = os.getenv("SHELL") or ""
local function is_valid_utf8(str)
return utf8.len(str) ~= nil
end
local function path_quote(path)
if not path or tostring(path) == "" then
return path
end
local result = "'" .. string.gsub(tostring(path), "'", "'\\''") .. "'"
return result
end
local function read_mediainfo_cached_file(file_path)
-- Open the file in read mode
local file = io.open(file_path, "r")
if file then
-- Read the entire file content
local content = file:read("*all")
file:close()
return content
end
end
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 force_render = ya.sync(function(_, _)
(ui.render or ya.render)()
end)
local function image_layer_count(job)
local cache = ya.file_cache({ file = job.file, skip = 0 })
if not cache then
return 0
end
local layer_count = get_state("f" .. tostring(cache))
if layer_count then
return layer_count
end
local output, err = Command("identify")
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
:output()
if err then
return 0
end
layer_count = 0
for line in output.stdout:gmatch("[^\r\n]+") do
if line:match("%S") then
layer_count = layer_count + 1
end
end
set_state("f" .. tostring(cache), layer_count)
return layer_count
end
function M:peek(job)
local start = os.clock()
local cache_img_url_no_skip = ya.file_cache({ file = job.file, skip = 0 })
if not job.mime then
return
end
set_state(STATE_KEY.prev_peek_data, {
file = tostring(job.file.path or job.file.cache or job.file.url),
mime = job.mime,
area = {
x = job.area.x,
y = job.area.y,
w = job.area.w,
h = job.area.h,
},
args = job.args,
skip = job.skip,
})
local is_video = string.find(job.mime, "^video/")
local is_audio = string.find(job.mime, "^audio/")
local is_image = string.find(job.mime, "^image/")
local is_seekable = seekable_mimes[job.mime] or is_video
local cache_img_url = (is_audio or is_image) and cache_img_url_no_skip
if is_seekable then
cache_img_url = ya.file_cache(job)
end
local preload_status, preload_err = self:preload(job)
if not preload_status then
return
end
ya.sleep(math.max(0, rt.preview.image_delay / 1000 + start - os.clock()))
local hide_metadata = get_state(STATE_KEY.hide_metadata)
local mediainfo_height = 0
local lines = {}
local limit = job.area.h
local last_line = 0
local is_wrap = rt.preview.wrap == "yes"
if not hide_metadata then
local cache_mediainfo_path = tostring(cache_img_url_no_skip) .. suffix
local output = read_mediainfo_cached_file(cache_mediainfo_path)
if output then
local max_width = math.max(1, job.area.w)
if output:match("^Error:") then
job.args.force_reload_mediainfo = true
preload_status, preload_err = self:preload(job)
if not preload_status or preload_err then
return
end
output = read_mediainfo_cached_file(cache_mediainfo_path)
end
for str in output:gsub("\n+$", ""):gmatch("[^\n]*") do
local label, value = str:match("(.*[^ ]) +: (.*)")
local line
if label then
if not skip_labels[label] then
line = ui.Line({
ui.Span(label .. ": "):style(ui.Style():fg("reset"):bold()),
ui.Span(value):style(th.spot.tbl_col or ui.Style():fg("blue")),
})
end
elseif str ~= "General" then
line = ui.Line({ ui.Span(str):style(th.spot.title or ui.Style():fg("green")) })
end
if line then
local line_height = math.max(1, is_wrap and math.ceil(ui.width(line) / max_width) or 1)
if (last_line + line_height) > job.skip then
table.insert(lines, line)
end
if (last_line + line_height) >= job.skip + limit then
last_line = job.skip + limit
break
end
last_line = last_line + line_height
end
end
end
mediainfo_height = math.min(limit, last_line)
end
if
(job.skip > 0 and #lines == 0 and not hide_metadata)
and (
not is_seekable
or (is_video and job.skip >= 90)
or (
(job.mime == "image/adobe.photoshop" or job.mime == "application/postscript")
and image_layer_count(job)
< (1 + math.floor(
math.max(0, get_state(STATE_KEY.units) and (job.skip / get_state(STATE_KEY.units)) or 0)
))
)
)
then
ya.emit("peek", {
math.max(0, job.skip - (get_state(STATE_KEY.units) or limit)),
only_if = job.file.url,
upper_bound = true,
})
return
end
force_render()
-- NOTE: Hacky way to prevent image overlap with old metadata area
if hide_metadata and get_state(STATE_KEY.prev_metadata_area) then
ya.preview_widget(job, {
ui.Clear(ui.Rect(get_state(STATE_KEY.prev_metadata_area))),
})
end
local rendered_img_rect = cache_img_url
and fs.cha(cache_img_url)
and ya.image_show(
cache_img_url,
ui.Rect({
x = job.area.x,
y = job.area.y,
w = job.area.w,
h = mediainfo_height > 0 and math.max(job.area.h - mediainfo_height, job.area.h / 2) or job.area.h,
})
)
or nil
local image_height = rendered_img_rect and rendered_img_rect.h or 0
-- NOTE: Workaround case audio has no cover image. Prevent regenerate preview image
if is_audio and image_height == 1 then
local info = ya.image_info(cache_img_url)
if not info or (info.w == 1 and info.h == 1) then
image_height = 0
end
end
-- NOTE: Workaround case video.lua doesn't doesn't generate preview image because of `skip` overflow video duration
if is_video and not rendered_img_rect then
image_height = math.max(job.area.h - mediainfo_height, 0)
end
-- Handle image preload error
if preload_err then
table.insert(lines, ui.Line(tostring(preload_err)):style(th.spot.title or ui.Style():fg("red")))
end
ya.preview_widget(job, {
ui.Text(lines)
:area(ui.Rect({
x = job.area.x,
y = job.area.y + image_height,
w = job.area.w,
h = job.area.h - image_height,
}))
:wrap(is_wrap and ui.Wrap.YES or ui.Wrap.NO),
})
-- NOTE: Hacky way to prevent image overlap with old metadata area
if not hide_metadata then
set_state(STATE_KEY.prev_metadata_area, {
x = job.area.x,
y = job.area.y + image_height,
w = job.area.w,
h = job.area.h - image_height,
})
end
end
function M:seek(job)
local h = cx.active.current.hovered
if h and h.url == job.file.url then
set_state(STATE_KEY.units, job.units)
ya.emit("peek", {
math.max(0, cx.active.preview.skip + job.units),
only_if = job.file.url,
})
end
end
function M:re_peek()
local prev_peek_data = get_state(STATE_KEY.prev_peek_data)
if prev_peek_data then
prev_peek_data.file = File({
url = Url(prev_peek_data.file),
cha = fs.cha(Url(prev_peek_data.file)),
})
prev_peek_data.area = ui.area and ui.area("preview") or ui.Rect(prev_peek_data.area)
self:peek(prev_peek_data)
end
end
function M:preload(job)
local cache_img_url = ya.file_cache({ file = job.file, skip = 0 })
if not cache_img_url then
return true
end
local cache_mediainfo_url = Url(tostring(cache_img_url) .. suffix)
cache_img_url = seekable_mimes[job.mime] and ya.file_cache(job) or cache_img_url
local cache_img_url_cha = cache_img_url and fs.cha(cache_img_url)
local err_msg = ""
local is_valid_utf8_path = is_valid_utf8(tostring(job.file.path or job.file.cache or job.file.url))
-- video mimetype
if job.mime then
if string.find(job.mime, "^video/") then
local cache_img_status, video_preload_err = require("video"):preload(job)
if not cache_img_status and video_preload_err then
err_msg = err_msg
.. string.format("Failed to start `%s`, Do you have `%s` installed?\n", "ffmpeg", "ffmpeg")
end
-- audo and image mimetype
elseif cache_img_url and (not cache_img_url_cha or cache_img_url_cha.len <= 0) then
-- audio
if string.find(job.mime, "^audio/") then
local qv = 31 - math.floor(rt.preview.image_quality * 0.3)
local audio_preload_output, audio_preload_err = Command("ffmpeg"):arg({
"-v",
"error",
"-threads",
1,
"-skip_frame",
"nokey",
"-an",
"-sn",
"-dn",
"-i",
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
"-vframes",
1,
"-q:v",
qv,
"-vf",
string.format("scale=-1:'min(%d,ih)':flags=fast_bilinear", rt.preview.max_height / 2),
"-f",
"image2",
"-y",
tostring(cache_img_url),
}):output()
-- NOTE: Some audio types doesn't have cover image -> error ""
if
(audio_preload_output and audio_preload_output.stderr ~= nil and audio_preload_output.stderr ~= "")
or audio_preload_err
then
err_msg = err_msg
.. string.format("Failed to start `%s`, Do you have `%s` installed?\n", "ffmpeg", "ffmpeg")
else
cache_img_url_cha, _ = fs.cha(cache_img_url)
if not cache_img_url_cha then
-- NOTE: Workaround case audio has no cover image. Prevent regenerate preview image
audio_preload_output, audio_preload_err = require("magick")
.with_limit()
:arg({
"-size",
"1x1",
"canvas:none",
string.format("PNG32:%s", cache_img_url),
})
:output()
if
(audio_preload_output.stderr ~= nil and audio_preload_output.stderr ~= "")
or audio_preload_err
then
err_msg = err_msg
.. string.format(
"Failed to start `%s`, Do you have `%s` installed?\n",
"magick",
"magick"
)
end
end
end
-- image
elseif string.find(job.mime, "^image/") or job.mime == "application/postscript" then
local svg_plugin_ok, svg_plugin = pcall(require, "svg")
local _, magick_plugin = pcall(require, "magick")
local mime = job.mime:match(".*/(.*)$")
local image_plugin = magick_image_mimes[mime]
and ((mime == "svg+xml" and svg_plugin_ok) and svg_plugin or magick_plugin)
or require("image")
local cache_img_status, image_preload_err
-- psd, ai, eps
if mime == "adobe.photoshop" or job.mime == "application/postscript" then
local layer_index = 0
local units = get_state(STATE_KEY.units)
if units ~= nil then
local max_layer = image_layer_count(job)
layer_index = math.floor(math.max(0, job.skip / units))
if layer_index + 1 > max_layer then
layer_index = max_layer - 1
end
end
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
if fs.cha(cache_img_url_tmp) then
fs.remove("file", cache_img_url_tmp)
end
local tmp_file_path, _ = fs.unique_name(cache_img_url_tmp)
cache_img_status, image_preload_err = magick_plugin
.with_limit()
:arg({
"-background",
"none",
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url)
.. "["
.. tostring(layer_index)
.. "]",
"-auto-orient",
"-strip",
"-resize",
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
"-quality",
rt.preview.image_quality,
string.format("PNG32:%s", tostring(tmp_file_path)),
})
:status()
if cache_img_status then
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
end
elseif mime == "svg+xml" and not is_valid_utf8_path then
local cache_img_url_tmp = Url(cache_img_url .. ".tmp")
if fs.cha(cache_img_url_tmp) then
fs.remove("file", cache_img_url_tmp)
end
local tmp_file_path, _ = fs.unique_name(cache_img_url_tmp)
-- svg under invalid utf8 path
cache_img_status, image_preload_err = magick_plugin
.with_limit()
:arg({
"-background",
"none",
tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url),
"-auto-orient",
"-strip",
"-flatten",
"-resize",
string.format("%dx%d>", rt.preview.max_width, rt.preview.max_height),
"-quality",
rt.preview.image_quality,
string.format("PNG32:%s", tostring(tmp_file_path)),
})
:status()
if cache_img_status then
os.rename(tostring(tmp_file_path), tostring(cache_img_url))
end
else
-- other image
local no_skip_job = { skip = 0, file = job.file, args = {} }
cache_img_status, image_preload_err = image_plugin:preload(no_skip_job)
end
if not cache_img_status then
err_msg = err_msg .. (image_preload_err and (tostring(image_preload_err)) or "")
end
end
end
end
local cache_mediainfo_cha = fs.cha(cache_mediainfo_url)
if cache_mediainfo_cha and not job.args.force_reload_mediainfo then
return true, err_msg ~= "" and ("Error: " .. err_msg) or nil
end
local cmd = "mediainfo"
local output, err
if is_valid_utf8_path then
output, err = Command(cmd)
:arg({ tostring(job.file.path or job.file.cache or job.file.url.path or job.file.url) })
:output()
else
cmd = "cd "
.. path_quote(job.file.path or job.file.cache or (job.file.url.path or job.file.url).parent)
.. " && "
.. cmd
.. " "
.. path_quote(tostring(job.file.path or job.file.cache or job.file.url.name))
output, err = Command(SHELL)
:arg({ "-c", cmd })
:arg({ tostring(job.file.path or job.file.cache or (job.file.url.path or job.file.url)) })
:output()
end
if err then
err_msg = err_msg .. string.format("Failed to start `%s`, Do you have `%s` installed?\n", cmd, cmd)
end
return fs.write(
cache_mediainfo_url,
(err_msg ~= "" and ("Error: " .. err_msg) or "") .. (output and output.stdout or "")
)
end
function M:entry(job)
local action = job.args[1]
if action == ENTRY_ACTION.toggle_metadata then
set_state(STATE_KEY.hide_metadata, not get_state(STATE_KEY.hide_metadata))
M:re_peek()
end
end
return M

View File

@@ -0,0 +1,56 @@
# mime-ext.yazi
A mime-type provider based on a file extension database, replacing the [builtin `file(1)`](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/mime.lua) to speed up mime-type retrieval at the expense of accuracy.
See https://yazi-rs.github.io/docs/tips#make-yazi-even-faster for more information.
## Installation
```sh
ya pkg add yazi-rs/plugins:mime-ext
```
## Usage
Add this to your `~/.config/yazi/yazi.toml`:
```toml
[[plugin.prepend_fetchers]]
id = "mime"
url = "*"
run = "mime-ext"
prio = "high"
```
## Advanced
You can also customize it in your `~/.config/yazi/init.lua` with:
```lua
require("mime-ext"):setup {
-- Expand the existing filename database (lowercase), for example:
with_files = {
makefile = "text/makefile",
-- ...
},
-- Expand the existing extension database (lowercase), for example:
with_exts = {
mk = "text/makefile",
-- ...
},
-- If the mime-type is not in both filename and extension databases,
-- then fallback to Yazi's preset `mime` plugin, which uses `file(1)`
fallback_file1 = false,
}
```
## TODO
- Add more file types (PRs welcome!).
- Compress mime-type tables.
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.

File diff suppressed because it is too large Load Diff

View File

@@ -4,8 +4,8 @@ A mount manager for Yazi, providing disk mount, unmount, and eject functionality
Supported platforms:
- Linux with [`udisksctl`](https://github.com/storaged-project/udisks) and [`lsblk`](https://github.com/util-linux/util-linux)
- macOS with `diskutil`
- Linux with [`udisksctl`](https://github.com/storaged-project/udisks), `lsblk` and `eject` both provided by [`util-linux`](https://github.com/util-linux/util-linux)
- macOS with `diskutil`, which is pre-installed
https://github.com/user-attachments/assets/c6f780ab-458b-420f-85cf-2fc45fcfe3a2
@@ -25,7 +25,9 @@ on = "M"
run = "plugin mount"
```
Available keybindings:
Note that, the keybindings above are just examples, please tune them up as needed to ensure they don't conflict with your other commands/plugins.
## Actions
| Key binding | Alternate key | Action |
| ------------ | ------------- | --------------------- |
@@ -40,7 +42,7 @@ Available keybindings:
## TODO
- Custom keybindings
- Windows support (I don't have an Windows machine for testing, PRs welcome!)
- Windows support (I don't use Windows myself, PRs welcome!)
- Support mount, unmount, and eject the entire disk
## License

View File

@@ -1,4 +1,4 @@
--- @since 25.5.31
--- @since 25.12.29
local toggle_ui = ya.sync(function(self)
if self.children then
@@ -7,7 +7,7 @@ local toggle_ui = ya.sync(function(self)
else
self.children = Modal:children_add(self, 10)
end
ya.render()
ui.render()
end)
local subscribe = ya.sync(function(self)
@@ -18,7 +18,7 @@ end)
local update_partitions = ya.sync(function(self, partitions)
self.partitions = partitions
self.cursor = math.max(0, math.min(self.cursor or 0, #self.partitions - 1))
ya.render()
ui.render()
end)
local active_partition = ya.sync(function(self) return self.partitions[self.cursor + 1] end)
@@ -29,12 +29,14 @@ local update_cursor = ya.sync(function(self, cursor)
else
self.cursor = ya.clamp(0, self.cursor + cursor, #self.partitions - 1)
end
ya.render()
ui.render()
end)
local M = {
keys = {
{ on = "q", run = "quit" },
{ on = "<Esc>", run = "quit" },
{ on = "<Enter>", run = { "enter", "quit" } },
{ on = "k", run = "up" },
{ on = "j", run = "down" },
@@ -209,6 +211,7 @@ function M.split(src)
{ "^/dev/nvme%d+n%d+", "p%d+$" }, -- /dev/nvme0n1p1
{ "^/dev/mmcblk%d+", "p%d+$" }, -- /dev/mmcblk0p1
{ "^/dev/disk%d+", ".+$" }, -- /dev/disk1s1
{ "^/dev/sr%d+", ".+$" }, -- /dev/sr0
}
for _, p in ipairs(pats) do
local main = src:match(p[1])
@@ -259,7 +262,10 @@ function M.operate(type)
output, err = Command("diskutil"):arg({ type, active.src }):output()
end
if ya.target_os() == "linux" then
if type == "eject" then
if type == "eject" and active.src:match("^/dev/sr%d+") then
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
output, err = Command("eject"):arg({ "--traytoggle", active.src }):output()
elseif type == "eject" then
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
output, err = Command("udisksctl"):arg({ "power-off", "-b", active.src }):output()
else

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 Anirudh Gupta
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.

View File

@@ -1,79 +0,0 @@
# nbpreview.yazi
View your Jupyter notebooks beautifully in the preview in Yazi.
## Requirements
- [Yazi](https://github.com/sxyazi/yazi) version >=0.4
- [nbpreview](https://github.com/paw-lu/nbpreview)
## Previews
<img width="1416" alt="image" src="https://github.com/AnirudhG07/nbpreview.yazi/assets/146579014/87535dc9-c45a-4eb7-a732-4384460b516d">
## Installation
```bash
ya pack -a AnirudhG07/nbpreview
## For linux and MacOS
git clone https://github.com/AnirudhG07/nbpreview.yazi.git ~/.config/yazi/plugins/nbpreview.yazi
## For Windows
git clone https://github.com/AnirudhG07/nbpreview.yazi.git %AppData%\yazi\config\plugins\nbpreview.yazi
```
## Usage
After installing the plugin, add this to your `yazi.toml` file inside the plugin's section previously present.
```toml
[plugin]
prepend_previewers = [
{ name = "*.ipynb", run = "nbpreview" },
]
```
## Configurations
You can configure your preview by editing the `init.lua` file present in the plugin directory.
<img width="724" alt="image" src="https://github.com/AnirudhG07/nbpreview.yazi/assets/146579014/99405d1f-3de8-4beb-a581-4a41affe8e57">
All the configurations provided using `nbpreview --help`.
By default we have give you some of the flags which you can change according to your needs in the `init.lua` file.
Please DONOT change the below options(unless you know what you are doing) -
- `--nerd-font` - Yazi uses nerd-font.
- \*`--decorated` - This enables the decorations you see in the preview.
- `--no-paging` - To avoid errors.
The `OPTIONAL CHANGES` flags are by default(recommended) given. You can add more or change as you wish.
## CUSTOMIZATION
You can Color customize your previews from the Color schemes and themes provided by `nbpreview`. These are -
```bash
# COLOR SCHEMES
--color-system, --cs [standard|256|truecolor|windows|none|auto]
The type of color system to use. [env var: NBPREVIEW_COLOR_SYSTEM]
# THEMES
-t, --theme [abap|algol|algol_nu|arduino|autumn|bw|borland|coffee|colorful|default|
dracula|emacs|friendly_grayscale|friendly|fruity|github-dark|gruvbox-dark|
gruvbox-light|igor|inkpot|lightbulb|lilypond|lovelace|manni|material|monokai|
murphy|native|nord-darker|nord|one-dark|paraiso-dark|paraiso-light|pastie|
perldoc|rainbow_dash|rrt|sas|solarized-dark|solarized-light|staroffice|stata-dark|
stata-light|tango|trac|vim|vs|xcode|zenburn|light|dark|ansi_light|ansi_dark]
```
You can change the default give color scheme and theme to any you like.
> [!Note]
>
> The loading of `ipynb` might appear slow. This is due to the lag created by the command itself and not because of the plugin or yazi
## Explore Yazi
Yazi is an amazing, blazing fast terminal file manager, with a variety of plugins, flavors and themes. Check them out at [awesome-yazi](https://github.com/AnirudhG07/awesome-yazi) and the official [yazi webpage](https://yazi-rs.github.io/).

View File

@@ -1,58 +0,0 @@
local M = {}
function M:peek(job)
local child = Command("nbpreview")
:arg({
-- DO NOT CHANGE --
"--no-paging",
"--nerd-font",
"--decorated",
-- OPTIONAL CHANGES --
"--no-files",
"--unicode",
"--color",
"--images",
-- SPECIAL CUSTOMIZATIONS --
"--color-system=standard",
"--theme=ansi_dark",
tostring(job.file.url),
})
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
if not child then
return require("code"):peek(job)
end
local limit = job.area.h
local i, lines = 0, ""
repeat
local next, event = child:read_line()
if event == 1 then
return require("code"):peek(job)
elseif event ~= 0 then
break
end
i = i + 1
if i > job.skip then
lines = lines .. next
end
until i >= job.skip + limit
child:start_kill()
if job.skip > 0 and i < job.skip + limit then
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
else
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
end
end
function M:seek(job)
require("code"):seek(job)
end
return M

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Sonico98
Copyright (c) 2024 ndtoan96
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -0,0 +1,92 @@
# ouch.yazi
[ouch](https://github.com/ouch-org/ouch) plugin for [Yazi](https://github.com/sxyazi/yazi).
![ouch.yazi](https://github.com/ndtoan96/ouch.yazi/assets/33489972/946397ec-b37b-4bf4-93f1-c676fc8e59f2)
## Features
- Archive preview
- Compression
## Installation
### Yazi package manager
```bash
ya pkg add ndtoan96/ouch
```
### Git
```bash
# Linux/macOS
git clone https://github.com/ndtoan96/ouch.yazi.git ~/.config/yazi/plugins/ouch.yazi
# Windows with cmd
git clone https://github.com/ndtoan96/ouch.yazi.git %AppData%\yazi\config\plugins\ouch.yazi
# Windows with powershell
git clone https://github.com/ndtoan96/ouch.yazi.git "$($env:APPDATA)\yazi\config\plugins\ouch.yazi"
```
Make sure you have [ouch](https://github.com/ouch-org/ouch) installed and in your `PATH`.
## Usage
### Preview
For archive preview, add this to your `yazi.toml`:
```toml
[[plugin.prepend_previewers]]
mime = "application/{*zip,tar,bzip2,7z*,rar,xz,zstd,java-archive}"
run = "ouch"
```
Now go to an archive on Yazi, you should see the archive's content in the preview pane. You can use `J` and `K` to roll up and down the preview.
#### Customization
Previews can be customized by adding extra arguments in the `run` string:
```toml
[plugin]
prepend_previewers = [
# Change the top-level archive icon
{ ..., run = "ouch --archive-icon='🗄️ '" },
# Or remove it by setting it to ''
{ ..., run = "ouch --archive-icon=''" },
# Enable file icons
{ ..., run = "ouch --show-file-icons" },
# Disable tree view
{ ..., run = "ouch --list-view" },
# These can be combined
{ ..., run = "ouch --archive-icon='🗄️ ' --show-file-icons --list-view" },
]
```
### Compression
For compession, add this to your `keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = ["C"]
run = "plugin ouch"
desc = "Compress with ouch"
```
The plugin uses `zip` format by default. You can change the format when you name the output file, `ouch` will detect format based on file extension.
And, for example, if you would like to set `7z` as default format, you can use `plugin ouch 7z`.
### Decompression
This plugin does not provide a decompression feature because it already is supported by Yazi.
To decompress with `ouch`, configure the opener in `yazi.toml`.
```toml
[opener]
extract = [
{ run = 'ouch d -y %*', desc = "Extract here with ouch", for = "windows" },
{ run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
]
```

View File

@@ -0,0 +1,195 @@
local M = {}
-- Extract the tree prefix (if any) from a line
local function get_tree_prefix(line)
local _, prefix_len = line:find("", 1, true)
if prefix_len then
return line:sub(1, prefix_len)
else
return ""
end
end
-- Add a filetype icon to a line
local function line_with_icon(line)
line = line:gsub("[\r\n]+$", "") -- Trailing newlines mess with filetype detection
local tree_prefix = get_tree_prefix(line)
local url = line:sub(#tree_prefix + 1)
local icon = File({
url = Url(url),
cha = Cha {
mode = tonumber(url:sub(-1) == "/" and "40700" or "100644", 8),
kind = url:sub(-1) == "/" and 1 or 0, -- For Yazi <25.9.x compatibility
}
}):icon()
if icon then
line = ui.Line { tree_prefix, ui.Span(icon.text .. " "):style(icon.style), url }
end
return line
end
function M:peek(job)
local cmd = Command("ouch"):arg("l")
if not job.args.list_view then
cmd:arg("-t")
end
cmd:arg({ "-y", tostring(job.file.url) })
:stdout(Command.PIPED)
:stderr(Command.PIPED)
local child = cmd:spawn()
local limit = job.area.h
local archive_icon = job.args.archive_icon or "\u{1f4c1} "
local file_name = string.match(tostring(job.file.url), ".*[/\\](.*)")
local lines = { string.format(" %s%s", archive_icon, file_name) }
local num_skip = 0
repeat
local line, event = child:read_line()
if event == 1 then
ya.err(tostring(event))
elseif event ~= 0 then
break
end
if line:find('Archive', 1, true) ~= 1 and line:find('[INFO]', 1, true) ~= 1 then
if num_skip >= job.skip then
if job.args.show_file_icons then
if line:find ('[ERROR]', 1, true) == 1 then
-- On error, disable file icons for the rest of the output
job.args.show_file_icons = false
elseif line:find ('[WARNING]', 1, true) ~= 1 then
-- Show icons for non-warning lines only
line = line_with_icon(line)
end
end
line = ui.Line { " ", line } -- One space padding
table.insert(lines, line)
else
num_skip = num_skip + 1
end
end
until #lines >= limit
child:start_kill()
if job.skip > 0 and #lines < limit then
ya.emit(
"peek",
{ tostring(math.max(0, job.skip - (limit - #lines))), only_if = tostring(job.file.url), upper_bound = "" }
)
else
ya.preview_widget(job, { ui.Text(lines):area(job.area) })
end
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", {
math.max(0, cx.active.preview.skip + step),
only_if = tostring(job.file.url),
})
end
end
-- Check if file exists
local function file_exists(name)
local f = io.open(name, "r")
if f ~= nil then
io.close(f)
return true
else
return false
end
end
-- Get the files that need to be compressed and infer a default archive name
local get_compression_target = ya.sync(function()
local tab = cx.active
local default_name
local paths = {}
if #tab.selected == 0 then
if tab.current.hovered then
local name = tab.current.hovered.name
default_name = name
table.insert(paths, name)
else
return
end
else
default_name = tab.current.cwd.name
for _, url in pairs(tab.selected) do
table.insert(paths, tostring(url))
end
-- The compression targets are aquired, now unselect them
ya.emit("escape", {})
end
return paths, default_name
end)
local function invoke_compress_command(paths, name)
local cmd_output, err_code = Command("ouch")
:arg({ "c", "-y" })
:arg(paths)
:arg(name)
:stderr(Command.PIPED)
:output()
if err_code ~= nil then
ya.notify({
title = "Failed to run ouch command",
content = "Status: " .. err_code,
timeout = 5.0,
level = "error",
})
elseif not cmd_output.status.success then
ya.notify({
title = "Compression failed: status code " .. cmd_output.status.code,
content = cmd_output.stderr,
timeout = 5.0,
level = "error",
})
end
end
function M:entry(job)
local default_fmt = job.args[1]
if default_fmt == nil then
default_fmt = "zip"
end
ya.emit("escape", { visual = true })
-- Get the files that need to be compressed and infer a default archive name
local paths, default_name = get_compression_target()
-- Get archive name from user
local output_name, name_event = ya.input({
title = "Create archive:",
value = default_name .. "." .. default_fmt,
position = { "top-center", y = 3, w = 40 },
pos = { "top-center", y = 3, w = 40 },
})
if name_event ~= 1 then
return
end
-- Get confirmation if file exists
if file_exists(output_name) then
local confirm, confirm_event = ya.input({
title = "Overwrite " .. output_name .. "? (y/N)",
position = { "top-center", y = 3, w = 40 },
pos = { "top-center", y = 3, w = 40 },
})
if not (confirm_event == 1 and confirm:lower() == "y") then
return
end
end
invoke_compress_command(paths, output_name)
end
return M

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 dawsers
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

View File

@@ -0,0 +1,98 @@
# piper.yazi
Pipe any shell command as a previewer.
## Installation
```sh
ya pkg add yazi-rs/plugins:piper
```
## Usage
Piper is a general-purpose previewer - you can pass any shell command to `piper` and it will use the command's output as the preview content.
It accepts a string parameter, which is the shell command to be executed, for example:
```toml
# ~/.config/yazi/yazi.toml
[[plugin.prepend_previewers]]
url = "*"
run = 'piper -- echo "$1"'
```
This will set `piper` as the previewer for all file types and use `$1` (file path) as the preview content.
## Variables
Available variables:
- `$w`: the width of the preview area.
- `$h`: the height of the preview area.
- `$1`: the path to the file being previewed.
## Examples
Here are some configuration examples:
### Preview tarballs with [`tar`](https://man7.org/linux/man-pages/man1/tar.1.html)
```toml
[[plugin.prepend_previewers]]
url = "*.tar*"
run = 'piper --format=url -- tar tf "$1"'
```
In this example, `--format=url` tells `piper` to parse the `tar` output as file URLs, so you'll be able to get a list of files with icons.
### Preview CSV with [`bat`](https://github.com/sharkdp/bat)
```toml
[[plugin.prepend_previewers]]
url = "*.csv"
run = 'piper -- bat -p --color=always "$1"'
```
Note that certain distributions might use a different name for `bat`, like Debian and Ubuntu uses `batcat` instead, so please adjust accordingly.
### Preview Markdown with [`glow`](https://github.com/charmbracelet/glow)
```toml
[[plugin.prepend_previewers]]
url = "*.md"
run = 'piper -- CLICOLOR_FORCE=1 glow -w=$w -s=dark "$1"'
```
Note that there's [a bug in Glow v2.0](https://github.com/charmbracelet/glow/issues/440#issuecomment-2307992634) that causes slight color differences between tty and non-tty environments.
### Preview directory tree with [`eza`](https://github.com/eza-community/eza)
```toml
[[plugin.prepend_previewers]]
url = "*/"
run = 'piper -- eza -TL=3 --color=always --icons=always --group-directories-first --no-quotes "$1"'
```
### Preview the schema of a SQLite database
```toml
[[plugin.prepend_previewers]]
mime = "application/sqlite3"
run = 'piper -- sqlite3 "$1" ".schema --indent"'
```
### Use [`hexyl`](https://github.com/sharkdp/hexyl) as fallback previewer
Yazi defaults to using [`file -bL "$1"`](https://github.com/sxyazi/yazi/blob/main/yazi-plugin/preset/plugins/file.lua) if there's no matched previewer.
This example uses `hexyl` as a fallback previewer instead of `file`.
```toml
[[plugin.append_previewers]]
url = "*"
run = 'piper -- hexyl --border=none --terminal-width=$w "$1"'
```
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.

View File

@@ -0,0 +1,71 @@
--- @since 25.9.15
local M = {}
local function fail(job, s) ya.preview_widget(job, ui.Text.parse(s):area(job.area):wrap(ui.Wrap.YES)) end
function M:peek(job)
local child, err = Command("sh")
-- TODO: use `job.file.path` instead
:arg({ "-c", job.args[1], "sh", tostring(job.file.cache or job.file.url) })
:env("w", job.area.w)
:env("h", job.area.h)
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:spawn()
if not child then
return fail(job, "sh: " .. err)
end
local limit = job.area.h
local i, outs, errs = 0, {}, {}
repeat
local next, event = child:read_line()
if event == 1 then
errs[#errs + 1] = next
elseif event ~= 0 then
break
end
i = i + 1
if i > job.skip then
outs[#outs + 1] = next
end
until i >= job.skip + limit
child:start_kill()
if #errs > 0 then
fail(job, table.concat(errs, ""))
elseif job.skip > 0 and i < job.skip + limit then
ya.emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
else
ya.preview_widget(job, M.format(job, outs))
end
end
function M:seek(job) require("code"):seek(job) end
function M.format(job, lines)
local format = job.args.format
if format ~= "url" then
local s = table.concat(lines, ""):gsub("\r", ""):gsub("\t", string.rep(" ", rt.preview.tab_size))
return ui.Text.parse(s):area(job.area)
end
for i = 1, #lines do
lines[i] = lines[i]:gsub("[\r\n]+$", "")
local icon = File({
url = Url(lines[i]),
cha = Cha { mode = tonumber(lines[i]:sub(-1) == "/" and "40700" or "100644", 8) },
}):icon()
if icon then
lines[i] = ui.Line { ui.Span(" " .. icon.text .. " "):style(icon.style), lines[i] }
end
end
return ui.Text(lines):area(job.area)
end
return M

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2024 Hunter Hwang
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

View File

@@ -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).

View File

@@ -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,
}

View File

@@ -0,0 +1,652 @@
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
project.tabs[#project.tabs + 1] = {
idx = index,
cwd = tostring(tab.current.cwd):gsub("\\", "/"),
}
end
return project
end)
local _save_projects = ya.sync(function(state, projects)
state.projects = projects
if state.save.method == "yazi" then
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
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 _, tab in pairs(sorted_tabs) do
ya.emit("tab_create", { tab.cwd })
end
ya.emit("tab_close", { 0 })
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
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
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"
ps.pub_to(0, state.merge.event, project)
if state.event.merge.enable then
ps.pub_to(0, state.event.merge.name, project)
end
if state.merge.quit_after_merge then
ya.emit("quit", {})
end
end)
local _merge_tab = ya.sync(function(state, tab)
ya.emit("tab_create", { tab.cwd })
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
_merge_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)]
_merge_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
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,
}

View File

@@ -14,15 +14,15 @@ Preview file types using `rich` command in Yazi. This plugin allows preview for
## Requirements
- [Yazi](https://github.com/sxyazi/yazi) v0.4 or higher.
- [rich-cli](https://github.com/Textualize/rich) v13.7.1 or higher.
- [Yazi](https://github.com/sxyazi/yazi) v25.4.8 or higher.
- [rich-cli](https://github.com/Textualize/rich-cli) v13.7.1 or higher.
## Installation
To install this plugin, simply run-
```bash
ya pack -a AnirudhG07/rich-preview
ya pkg add AnirudhG07/rich-preview
## For linux and MacOS
git clone https://github.com/AnirudhG07/rich-preview.yazi.git ~/.config/yazi/plugins/rich-preview.yazi
@@ -40,12 +40,12 @@ Add the below to your `yazi.toml` file to allow the respective file to previewed
[plugin]
prepend_previewers = [
{ name = "*.csv", run = "rich-preview"}, # for csv files
{ name = "*.md", run = "rich-preview" }, # for markdown (.md) files
{ name = "*.rst", run = "rich-preview"}, # for restructured text (.rst) files
{ name = "*.ipynb", run = "rich-preview"}, # for jupyter notebooks (.ipynb)
{ name = "*.json", run = "rich-preview"}, # for json (.json) files
# { name = "*.lang_type", run = "rich-preview"} # for particular language files eg. .py, .go., .lua, etc.
{ url = "*.csv", run = "rich-preview"}, # for csv files
{ url = "*.md", run = "rich-preview" }, # for markdown (.md) files
{ url = "*.rst", run = "rich-preview"}, # for restructured text (.rst) files
{ url = "*.ipynb", run = "rich-preview"}, # for jupyter notebooks (.ipynb)
{ url = "*.json", run = "rich-preview"}, # for json (.json) files
# { url = "*.lang_type", run = "rich-preview"} # for particular language files eg. .py, .go., .lua, etc.
]
```
@@ -70,6 +70,20 @@ You can add more, remove and choose themes as you wish. You can set styles or Th
Currently the colors maynot be uniformly present, along with weird lines here and there. This is due to `"--force-terminal"` option. You can disable it if you find it annoying. Work is in progress to possibly fix the issue.
## Using piper.yazi
[piper.yazi](https://github.com/yazi-rs/plugins/tree/main/piper.yazi) is a general-purpose previewer - you can pass any shell command to piper and it will use the command's output as the preview content.
To use `rich` with piper, you can add this in your `yazi.toml` file:
```toml
[[plugin.prepend_previewers]]
url = "*.md"
run = 'piper -- rich -j --left --panel=rounded --guides --line-numbers --force-terminal "$1"'
```
Note you can also add other filetypes as mentioned above in the same format.
# Explore Yazi
Yazi is an amazing, blazing fast terminal file manager, with a variety of plugins, flavors and themes. Check them out at [awesome-yazi](https://github.com/AnirudhG07/awesome-yazi) and the official [yazi webpage](https://yazi-rs.github.io/).

View File

@@ -39,10 +39,13 @@ function M:peek(job)
child:start_kill()
if job.skip > 0 and i < job.skip + limit then
ya.manager_emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
ya.emit("peek", { math.max(0, i - limit), only_if = job.file.url, upper_bound = true })
else
lines = lines:gsub("\t", string.rep(" ", PREVIEW.tab_size))
ya.preview_widgets(job, { ui.Text.parse(lines):area(job.area) })
lines = lines:gsub("\t", string.rep(" ", rt.preview.tab_size))
ya.preview_widget(
job,
ui.Text.parse(lines):area(job.area):wrap(rt.preview.wrap == "yes" and ui.Wrap.YES or ui.Wrap.NO)
)
end
end

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2022 Himanshu
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

View File

@@ -0,0 +1,56 @@
# rsync.yazi
A [yazi](https://yazi-rs.github.io/) plugin for simple rsync copying locally and up to remote servers.
![Demo](assets/demo.gif)
Thanks to [chrissabug](https://x.com/chrissabug) for creating lovely art!
## Pre-reqs
1. yazi 3.0+
2. rsync
3. passwordless authentication if copying to a remote server
## Installation
```sh
ya pkg add GianniBYoung/rsync
```
## Usage
Add the binds to your `~/.config/yazi/keymap.toml`
**WARNING:** Make sure the chosen binding isn't already in use!!
```toml
[[mgr.prepend_keymap]]
on = [ "R" ]
run = "plugin rsync"
desc = "Copy files using rsync"
```
### Specify Default Remote Server
```toml
[[mgr.prepend_keymap]]
on = [ "R" ]
run = "plugin rsync 'user@server.com'"
desc = "Copy files using rsync to default location"
```
## Troubleshooting
Basic logging information is sent to `~/.local/state/yazi/yazi.log`
*Note: This plugin has only been tested on linux
## Contributing
Run into a bug or want a certain feature added? Submit an issue!
PRs welcome :)
Please keep in mind the yazi plugin system is still very new - as more features are added
more possibilities will open up for this plugin!

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 MiB

Binary file not shown.

View File

@@ -0,0 +1,117 @@
-- function borrowed from chmod.yazi plugin
local selected_or_hovered = ya.sync(function()
local tab = cx.active
local paths = {}
-- count up selected files
for _, url in pairs(tab.selected) do
paths[#paths + 1] = tostring(url)
end
-- if no files are selected use the hovered file
-- a tab has folders which have files which have urls
if #paths == 0 and tab.current.hovered then
-- lua so we are 1 indexed
paths[1] = tostring(tab.current.hovered.url)
end
return paths
end)
-- Helper function to expand tilde (~) in a path
local function expand_tilde(path)
if not path then
return nil
end
if path:sub(1, 1) == "~" then
local home = os.getenv("HOME") -- Get HOME environment variable
if not home then
-- Fallback for Windows-specific environment variables
home = os.getenv("USERPROFILE") -- Primary user profile directory on Windows
end
if home then
return home .. path:sub(2) -- Concatenate home path with the rest of the path
else
-- Fallback if HOME is not set
ya.notify({
title = "Rsync Plugin",
content = "Could not expand '~': HOME environment variable not set.",
level = "warn",
timeout = 5,
})
return path -- Return original path if home cannot be determined
end
end
return path -- Return original path if no tilde
end
return {
entry = function(_, job)
ya.mgr_emit("escape", { visual = true })
local remote_target = job.args and #job.args >= 1 and job.args[1] or nil
local files = selected_or_hovered()
if #files == 0 then
return ya.notify({ title = "Rsync", content = "No files selected", level = "warn", timeout = 3 })
end
local default_dest = ""
if #files == 1 and remote_target ~= nil then
local base_name = files[1]:match("([^/]+)$")
default_dest = remote_target .. ":" .. base_name
ya.err({ default_dest = default_dest })
end
local dest, ok = ya.input({
title = "Rsync - [user]@[remote]:<destination>",
value = default_dest or nil,
pos = { "top-center", y = 3, w = 45 },
})
if ok ~= 1 then
return
end
-- Only expand tilde if it's a local path (doesn't contain ':')
if not dest:match(":") then
dest = expand_tilde(dest)
if not dest then
return
end -- If expand_tilde failed and returned nil
end
-- local cmd, err = Command("rsync"):args(files):arg(dest):stderr(Command.PIPED):output()
local cmd, err = Command("rsync")
:arg({ "-ahP", "--no-motd" })
:arg(files)
:arg(dest)
:stdout(Command.PIPED)
:stderr(Command.PIPED)
:output()
local stderr = cmd.stderr
local stdout = cmd.stdout
local return_code = cmd.status.code
ya.err({
stderr = stderr,
stdout = stdout,
err = err,
res = cmd.status.success,
return_code = return_code,
default_dest = default_dest,
})
if return_code ~= 0 then
ya.notify({
title = "Rsync Plugin",
content = string.format("stderr below, exit code %s\n\n%s", cmd.status.code, stderr),
level = "error",
timeout = 10,
})
else
ya.notify({
title = "Rsync Plugin",
content = "Rsync Completed!",
timeout = 3,
})
end
end,
}

View File

@@ -0,0 +1,19 @@
Copyright (c) 2025 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.

View File

@@ -0,0 +1,424 @@
# simple-tag
<!--toc:start-->
- [simple-tag](#simple-tag)
- [Overview](#overview)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Previews](#previews)
- [Configuration](#configuration)
- [Add setup function in `yazi/init.lua`.](#add-setup-function-in-yaziinitlua)
- [Fetcher Configuration in `yazi.toml`](#fetcher-configuration-in-yazitoml)
- [Keybindings in `keymap.toml`](#keybindings-in-keymaptoml)
- [Customizing the Theme for tag hints window](#customizing-the-theme-for-tag-hints-window)
- [For Developers](#for-developers)
<!--toc:end-->
## Overview
simple-tag is a Yazi plugin that allows you to add tags to files and folders. Each tag is associated with a unique key.
> Disclaimer: This is not mactag and does not utilize mactag.
## Features
- Toggle, Add, Remove, Replace, Clear, Edit Tag(s). Supported input multiple tags.
- Filter Files/Folders by Tag(s).
- Visual Selection files/folders by Tag(s) (Replace, Unite, Subtract, Intersect, Exclude). Undo/Redo visual selection.
- Change Tag Icon/Text/Hidden Indicator.
- Tag Hints, will show up whenever you need to input or select tag(s).
- Automatically transfer tags after moving/renaming/bulk-renaming files/folders.
- Automatically clear tags when files/folders are deleted or trashed.
## Requirements
> [!IMPORTANT]
> Minimum supported version: Yazi v25.5.31.
- [Yazi](https://github.com/sxyazi/yazi)
- Tested on Linux and Windows
## Installation
Install the plugin:
```sh
ya pkg add boydaihungst/simple-tag
```
> [!IMPORTANT]
> Tags are automatically cleared when files/folders are deleted or moved to trash within Yazi.
> However, if deleted outside Yazi and then recreated, their tags will be restored.
> It also apply with renaming and moving files/folders.
## Previews
- Tag Hints, will show up whenever you need to input or select tag(s).
Only custom Icons or colors are shown.
![image](https://github.com/user-attachments/assets/5b5b9baa-044d-4fe8-a09a-46ec915b94c3)
- Tag Icon/Text/Hidden Indicator:
![Recording 2025-03-29 at 20 49 49](https://github.com/user-attachments/assets/261bfd3f-3249-45b0-a59a-10e2f44a70eb)
- Toggle Tag(s):
![Recording 2025-03-29 at 21 10 38](https://github.com/user-attachments/assets/8cdf108c-8951-4da6-a9f4-b542ab0ce8d4)
- Add, Remove, Replace, Edit Tag(s):
![Recording 2025-03-29 at 21 30 13](https://github.com/user-attachments/assets/2c5bef3b-cb9f-49ca-976f-fb5bad5bc323)
- Filter Files by Tag(s) and Modes:
In all of examples below, I didn't use fixed tag keys with `--keys`/`--key`/`--tag`/`--tags`
- Mode = and (Default), match all of the selected tags:
![Recording 2025-03-29 at 20 56 47](https://github.com/user-attachments/assets/e7619681-7ab8-4e2c-b8ea-ea4aeb8c22db)
- Mode = or, match at least one of the selected tags:
![Recording 2025-03-29 at 21 01 39](https://github.com/user-attachments/assets/cf9e757f-d910-4dca-aec5-cf9c36e54f34)
- Visual Selection Modes:
In all of examples below, I didn't use fixed tag keys with `--keys`/`--key`/`--tag`/`--tags`
![image](https://github.com/user-attachments/assets/6efabb8a-0022-4aa3-ba20-04127e3c58c1)
- Replace selection:
![Recording 2025-03-29 at 23 30 56](https://github.com/user-attachments/assets/364c07a7-c1ef-4323-8e92-ccb795233fd7)
- Unite selection:
![Recording 2025-03-29 at 23 36 59](https://github.com/user-attachments/assets/915ed231-f553-4eec-aaf0-5c0f0f56b729)
- Subtract selection:
![Recording 2025-03-29 at 23 45 42](https://github.com/user-attachments/assets/fac67ebb-2a77-49a6-955b-ab4e08ee4066)
- Intersect selection:
![Recording 2025-03-29 at 23 51 17](https://github.com/user-attachments/assets/6f46e221-d43e-49b7-8e9c-6f4aa1317e3b)
- Exclude selection:
![Recording 2025-08-06 at 16 31 31](https://github.com/user-attachments/assets/c8124b16-803d-48a4-9d44-e345060629d6)
- Undo selection:
![Recording 2025-03-29 at 23 54 55](https://github.com/user-attachments/assets/abf7ccc7-7591-4683-84f9-53e8cb9a280e)
## Configuration
### Add setup function in `yazi/init.lua`.
The setup function is required, while preferences are optional.
```lua
require("simple-tag"):setup({
-- UI display mode (icon, text, hidden)
ui_mode = "icon", -- (Optional)
-- Disable tag key hints (popup in bottom right corner)
hints_disabled = false, -- (Optional)
-- linemode order: adjusts icon/text position. For example, if you want icon to be on the most left of linemode then set linemode_order larger than 1000.
-- More info: https://github.com/sxyazi/yazi/blob/077faacc9a84bb5a06c5a8185a71405b0cb3dc8a/yazi-plugin/preset/components/linemode.lua#L4-L5
linemode_order = 500, -- (Optional)
-- You can backup/restore this folder within the same OS (Linux, windows, or MacOS).
-- But you can't restore backed up folder in the different OS because they use difference absolute path.
-- save_path = -- full path to save tags folder (Optional)
-- - Linux/MacOS: os.getenv("HOME") .. "/.config/yazi/tags"
-- - Windows: os.getenv("APPDATA") .. "\\yazi\\config\\tags"
-- Set tag colors
colors = { -- (Optional)
-- Set this same value with `theme.toml` > [mgr] > hovered > reversed
-- Default theme use "reversed = true".
-- More info: https://github.com/sxyazi/yazi/blob/077faacc9a84bb5a06c5a8185a71405b0cb3dc8a/yazi-config/preset/theme-dark.toml#L25
reversed = true, -- (Optional)
-- More colors: https://yazi-rs.github.io/docs/configuration/theme#types.color
-- format: [tag key] = "color"
["*"] = "#bf68d9", -- (Optional)
["$"] = "green",
["!"] = "#cc9057",
["1"] = "cyan",
["p"] = "red",
},
-- Set tag icons. Only show when ui_mode = "icon".
-- Any text or nerdfont icons should work as long as you use nerdfont to render yazi.
-- Default icon from mactag.yazi: ●; Some generic icons: , , 󱈤
-- More icon from nerd fonts: https://www.nerdfonts.com/cheat-sheet
icons = { -- (Optional)
-- default icon
default = "󰚋",
-- format: [tag key] = "tag icon"
["*"] = "*",
["$"] = "",
["!"] = "",
["p"] = "",
},
})
```
### Fetcher Configuration in `yazi.toml`
Use one of the following methods:
> [!IMPORTANT]
>
> For yazi before v25.12.29 replace `url` with `name`
```toml
[plugin]
fetchers = [
{ id = "simple-tag", url = "*", run = "simple-tag" },
{ id = "simple-tag", url = "*/", run = "simple-tag" },
]
# or
prepend_fetchers = [
{ id = "simple-tag", url = "*", run = "simple-tag" },
{ id = "simple-tag", url = "*/", run = "simple-tag" },
]
# or
append_fetchers = [
{ id = "simple-tag", url = "*", run = "simple-tag" },
{ id = "simple-tag", url = "*/", run = "simple-tag" },
]
```
### Keybindings in `keymap.toml`
> [!IMPORTANT]
> Ensure there are no conflicts with [default Keybindings](https://github.com/sxyazi/yazi/blob/main/yazi-config/preset/keymap-default.toml).
Since Yazi prioritizes the first matching key, `prepend_keymap` takes precedence over defaults.
Or you can use `keymap` to replace all other keys
```toml
[mgr]
prepend_keymap = [
# Tagging plugin
#─────────────────────────── TOGGLE TAG(S) ────────────────────────────
# Toggle a tag (press any tag key)
# A tag hint window will show up.
# Simply press any tag key to toggle that tag for selected or hovered files/folders.
{ on = [ "t", "t", "k" ], run = "plugin simple-tag -- toggle-tag", desc = "Toggle a tag (press any key)" },
# Fast Toggle tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
# NOTE: For key=" (Quotation mark), then use key=\" (Backslash + Quotation mark) instead.
{ on = [ "`" ], run = "plugin simple-tag -- toggle-tag --keys=!1q", desc = "Toggle tag(s) with fixed tag key(s) = (! and 1 and q)" },
{ on = [ "`" ], run = "plugin simple-tag -- toggle-tag --keys=*", desc = "Toggle tag with fixed tag key = *" },
{ on = [ "`" ], run = "plugin simple-tag -- toggle-tag --key=*", desc = "Toggle tag with fixed tag key = *" },
# Toggle tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input tag key(s) to toggle that tags for selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "t", "i" ], run = "plugin simple-tag -- toggle-tag --input", desc = "Toggle tag(s) with value from (input box)" },
#─────────────────────────── ADD TAG(S) ───────────────────────────────
# Add a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key to add to selected or hovered files/folders.
{ on = [ "t", "a", "k" ], run = "plugin simple-tag -- add-tag", desc = "Add a tag (press any key)" },
# Fast Add tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --keys=!1q", desc = "Add tag(s) with fixed tag keys = (! and 1 and q)" },
{ on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --keys=*", desc = "Add tag with fixed tag key = *" },
{ on = [ "t", "a", "f" ], run = "plugin simple-tag -- add-tag --key=*", desc = "Add tag with fixed tag key = *" },
# Add tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input new tag key(s) to add to selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "a", "i" ], run = "plugin simple-tag -- add-tag --input", desc = "Add tag(s) with value from (input box)" },
#─────────────────────────── REMOVE/DELETE TAG(S) ───────────────────────────
# Remove a tag (press any tag key)
# A tag hint window will show up.
# Simply press any tag key to be removed from selected or hovered files/folders.
{ on = [ "t", "d", "k" ], run = "plugin simple-tag -- remove-tag", desc = "Remove a tag (press any key)" },
# Fast Remove tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --keys=!1q", desc = "Remove tag(s) with fixed tag keys = (! and 1 and q)" },
{ on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --keys=*", desc = "Remove tag with fixed tag key = *" },
{ on = [ "t", "d", "f" ], run = "plugin simple-tag -- remove-tag --key=*", desc = "Remove tag with fixed tag key = *" },
# Remove tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input tag key(s) to be removed from selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "d", "i" ], run = "plugin simple-tag -- remove-tag --input", desc = "Remove tag(s) with value from (input box)" },
#─────────────────────────── REPLACE ALL OLD TAG(S) WITH NEW TAG(S) ───────────────────────────
# Replace a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key for selected or hovered files/folders.
{ on = [ "t", "r", "k" ], run = "plugin simple-tag -- replace-tag", desc = "Replace with a new tag (press any key)" },
# Fast Replace tag(s) with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
{ on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --keys=!1q", desc = "Replace tag(s) with fixed tag keys = (! and 1 and q)" },
{ on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --keys=*", desc = "Replace tag(s) with fixed tag key = *" },
{ on = [ "t", "r", "f" ], run = "plugin simple-tag -- replace-tag --key=*", desc = "Replace tag(s) with fixed tag key = *" },
# Replace tag(s) with value from input box.
# A tag hint window and an input box will show up.
# Simply input new tag key(s) for selected or hovered files/folders.
# Do not input any delimiter.
{ on = [ "t", "r", "i" ], run = "plugin simple-tag -- replace-tag --input", desc = "Replace tag(s) with value from (input box)" },
#─────────────────────────── EDIT TAG(S) ───────────────────────────
# Edit a tag for hovered or selected files/folders
# An input box with current tagged keys and a tag hint window will show up for each hovered or selected files/folders.
# Simply edit tag key(s) for selected or hovered files/folders.
# If you cancel any input box, all changes will be discarded.
{ on = [ "t", "e" ], run = "plugin simple-tag -- edit-tag ", desc = "Edit tag(s) (input box)" },
# ───────────────────────────── CLEAR TAG(S) ─────────────────────────────
# Clear all tags from selected or hovered files/folders
{ on = [ "t", "c" ], run = "plugin simple-tag -- clear", desc = "Clear all tags from selected or hovered files" },
# ───────────────────────────── CHANGE UI ─────────────────────────────
# Switch tag indicator between icon > tag key > hidden.
# Useful when u don't remember the tag key
{ on = [ "t", "u", "s" ], run = "plugin simple-tag -- toggle-ui", desc = "Toggle tag indicator (icon > tag key > hidden)" },
# Fixed tag indicator mode = hidden (Available modes: hidden|icon|text)
{ on = [ "t", "u", "h" ], run = "plugin simple-tag -- toggle-ui --mode=hidden", desc = "Hide all tags indicator" },
# ─────────────────────── FILTER FILES/FOLDERS BY TAGS: ───────────────────────
# Available filter modes:
# and → Filter files which contain all of selected tags (Default if mode isn't specified).
# or → Filter files which contain at least one of selected tags.
# NOTE: Not available in vfs mode (Remote Virtual Filesystem)
# Filter files/folders by tags
# Filter files/folders by a tag (press any tag key)
# A tag hint window will show up.
# Simply press any new tag key to filter files/folders containing that tag in current directory.
{ on = [ "t", "f" ], run = "plugin simple-tag -- filter", desc = "Filter files/folders by a tag (press any key)" },
# Fast Filter files/folders with fixed keys=!1q. key=!1q tag=!1q or tags=!1q also work
# { on = [ "t", "f" ], run = "plugin simple-tag -- filter --key=!", desc = "Filter files/folders by a fixed tag = !" },
# { on = [ "t", "f" ], run = "plugin simple-tag -- filter --keys=!1q", desc = "Filter files/folders by multiple fixed tag(s) (! and 1 and q)" },
# Filter files/folders by tag(s) with value from input box.
# An input box and a tag hint window will show up.
# Simply input tag key(s) to filter files/folders of current directory.
# Do not input any delimiter.
# For example: Input value or --keys=!1q -> filter any files/folders contain all of these tags (! and 1 and q) in current directory.
{ on = [ "t", "F" ], run = "plugin simple-tag -- filter --input", desc = "Filter files/folders by tag(s) (input box)" },
# Filter files/folders by tag(s) with --mode=or.
# --mode=or -> Input value or --keys = !1q -> filter any files/folders contain at least one of these tags (! or 1 or q)
{ on = [ "t", "F" ], run = "plugin simple-tag -- filter --input --mode=or", desc = "Filter files/folders by contain tags (input box)" },
# { on = [ "t", "F" ], run = "plugin simple-tag -- filter --keys=!1q --mode=or", desc = "Filter files/folders by multiple fixed tag(s) (! or 1 or q)" },
# ─────────────────────── VISUAL SELECT FILES/FOLDERS BY TAGS: ───────────────────────
# Available selection actions:
# replace → Replaces the current selection list with files/folders that have the selected tag.
# unite → Combines the currently selected files/folders with those that have the selected tag.
# intersect → Keeps only the files/folders that are present in both the current selection and the tagged items.
# subtract → Deselects files/folders that have the selected tag from the current selection.
# exclude → Combines the currently selected files/folders with the tagged items, then deselects any overlapping items between the current selection and the tagged items.
# undo → Undos or redoes the last selection action.
# which_key will popup to choose selection mode
# And a tag hint window will show up.
# Simply select a selection mode then press any tag key to select files/folders
{ on = [ "t", "s", "t" ], run = "plugin simple-tag -- toggle-select", desc = "Select a selection action then select a tag key (toggle-select)" },
# fixed tag(s). --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q. They are the same.
{ on = [ "t", "s", "t" ], run = "plugin simple-tag -- toggle-select --keys=!1q", desc = "" },
# Run action on files/folders by a tag.
# A tag hint window will show up.
# Simply press any tag key to do the following action:
{ on = [ "t", "s", "r" ], run = "plugin simple-tag -- replace-select", desc = "replace-select" },
{ on = [ "t", "s", "u" ], run = "plugin simple-tag -- unite-select", desc = "unite-select" },
{ on = [ "t", "s", "i" ], run = "plugin simple-tag -- intersect-select", desc = "intersect-select" },
{ on = [ "t", "s", "s" ], run = "plugin simple-tag -- subtract-select", desc = "subtract-select" },
{ on = [ "t", "s", "e" ], run = "plugin simple-tag -- exclude-select", desc = "exclude-select" },
# Run action on files/folders by fixed tag(s). --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q. They are the same.
{ on = [ "t", "s", "e" ], run = "plugin simple-tag -- replace-select --keys=!1q", desc = "Replaces the current selection list with files/folders that have (! and 1 and q) tag(s)" },
# Run action on files/folders by tag(s) with value from input box.
# A tag hint window will show up.
# Simply input tag key(s) to do the following action:
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --input", desc = "replace-select --input" },
{ on = [ "t", "s", "U" ], run = "plugin simple-tag -- unite-select --input", desc = "unite-select --input" },
{ on = [ "t", "s", "I" ], run = "plugin simple-tag -- intersect-select --input", desc = "intersect-select --input" },
{ on = [ "t", "s", "S" ], run = "plugin simple-tag -- subtract-select --input", desc = "subtract-select --input" },
{ on = [ "t", "s", "E" ], run = "plugin simple-tag -- exclude-select --input", desc = "exclude-select --input" },
# it also support --mode=or when using with --input or --keys=!1q or --key=!1q or --tag=!1q or --tags=!1q
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --input --mode=or", desc = "replace-select --input --mode=or" },
{ on = [ "t", "s", "R" ], run = "plugin simple-tag -- replace-select --keys=!1q --mode=or", desc = "replace-select --keys=!1q --mode=or" },
# Undo/Redo selection (only works after using 5 modes above)
{ on = [ "t", "s", "u" ], run = "plugin simple-tag -- undo-select", desc = "Undos/Redos the last selection action" },
]
```
### Customizing the Theme for tag hints window
To modify the tag hints window appearance, edit `.../yazi/theme.toml`:
You can also use Flavors file instead.
```toml
[spot]
border = { fg = "#4fa6ed" }
title = { fg = "#4fa6ed" }
```
## For Developers
You can trigger this plugin programmatically:
```lua
-- In your plugin:
local simple_tag = require("simple-tag")
-- Available actions: toggle-tag, toggle-ui, clear, toggle-select, filter, add-tag, remove-tag, replace-tag, edit-tag
local action = "toggle-select"
local args = ya.quote(action)
args = args .. " " .. ya.quote("--mode=unite")
-- another arguments
-- args = args .. " " .. ya.quote("--tag=q")
ya.emit("plugin", {
simple_tag._id,
args,
})
-- Special action: "files-deleted" -> clear all tags from these files/folders
local args = ya.quote("files-deleted")
-- A array of string url
local files_to_clear_tags = selected_or_hovered_files()
for _, url in ipairs(files_to_clear_tags) do
args = args .. " " .. ya.quote(url)
end
ya.emit("plugin", {
simple_tag._id,
args,
})
```

File diff suppressed because it is too large Load Diff

View File

@@ -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.

View File

@@ -0,0 +1,40 @@
# smart-enter.yazi
[`Open`][open] files or [`enter`][enter] directories all in one key!
## Installation
```sh
ya pkg add yazi-rs/plugins:smart-enter
```
## Usage
Bind your <kbd>l</kbd> key to the plugin, in your `~/.config/yazi/keymap.toml`:
```toml
[[mgr.prepend_keymap]]
on = "l"
run = "plugin smart-enter"
desc = "Enter the child directory, or open the file"
```
## Advanced
By default, `--hovered` is passed to the [`open`][open] command, make the behavior consistent with [`enter`][enter] avoiding accidental triggers,
which means both will only target the currently hovered file.
If you still want `open` to target multiple selected files, add this to your `~/.config/yazi/init.lua`:
```lua
require("smart-enter"):setup {
open_multi = true,
}
```
## License
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
[open]: https://yazi-rs.github.io/docs/configuration/keymap/#mgr.open
[enter]: https://yazi-rs.github.io/docs/configuration/keymap/#mgr.enter

View File

@@ -0,0 +1,11 @@
--- @since 25.5.31
--- @sync entry
local function setup(self, opts) self.open_multi = opts.open_multi end
local function entry(self)
local h = cx.active.current.hovered
ya.emit(h and h.cha.is_dir and "enter" or "open", { hovered = not self.open_multi })
end
return { entry = entry, setup = setup }

View File

@@ -1,35 +0,0 @@
# time-travel.yazi
A Yazi plugin for browsing backwards and forwards in time via BTRFS / ZFS snapshots.
https://github.com/user-attachments/assets/6d2fc9e7-f86e-4444-aab6-4e11e51e8b34
## Installation
```sh
ya pack -a iynaix/time-travel
```
## Usage
Add keymaps similar to the following to your `~/.config/yazi/keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = ["z", "h"]
run = "plugin time-travel --args=prev"
desc = "Go to previous snapshot"
[[manager.prepend_keymap]]
on = ["z", "l"]
run = "plugin time-travel --args=next"
desc = "Go to next snapshot"
[[manager.prepend_keymap]]
on = ["z", "e"]
run = "plugin time-travel --args=exit"
desc = "Exit browsing snapshots"
```
#### Note for BTRFS
`sudo` is required to run btrfs commands such as `btrfs subvolume list`, the plugin will drop into a terminal to prompt for the password.

View File

@@ -1,386 +0,0 @@
---@param msg string
local notify_warn = function(msg)
ya.notify { title = "ZFS", content = msg, level = "warn", timeout = 5 }
end
---@param msg string
local notify_error = function(msg)
ya.notify { title = "ZFS", content = msg, level = "error", timeout = 5 }
end
---@param arr table
---@param predicate fun(value: any): boolean
---@return number|nil # index if found, nil if not found
local find_index = function(arr, predicate)
for i, value in ipairs(arr) do
if predicate(value) then
return i
end
end
return nil
end
--- Verify if `sudo` is already authenticated
--- @return boolean
local function sudo_already()
local status = Command("sudo"):arg({ "--validate", "--non-interactive" }):status()
assert(status, "Failed to run `sudo --validate --non-interactive`")
return status.success
end
--- Run a program with `sudo` privilege
--- @param program string
--- @param arg table
--- @return Output|nil output
--- @return integer|nil err
--- nil: no error
--- 1: sudo failed
local function run_with_sudo(program, arg)
local cmd = Command("sudo"):arg({ program, table.unpack(arg) }):stdout(Command.PIPED):stderr(Command.PIPED)
if sudo_already() then
return cmd:output()
end
local permit = ya.hide()
print(string.format("Sudo password required to run: `%s %s`", program, table.concat(arg, " ")))
local output = cmd:output()
permit:drop()
if output.status.success or sudo_already() then
return output
end
return nil, 1
end
---@return string
local get_cwd = ya.sync(function()
return tostring(cx.active.current.cwd)
end)
---@param s string
---@return string
local trim = function(s)
return s:match("^%s*(.-)%s*$")
end
---@param cwd string
---@return string|nil
local get_filesystem_type = function(cwd)
local stat, _ = Command("stat"):arg({ "-f", "-c", "%T", cwd }):output()
if not stat.status.success then
return nil
end
return trim(stat.stdout)
end
---@param cwd string
---@return string|nil
local zfs_dataset = function(cwd)
local df, _ = Command("df"):arg({ "--output=source", cwd }):output()
local dataset = nil
for line in df.stdout:gmatch("[^\r\n]+") do
-- dataset is last line in output
dataset = line
end
return dataset
end
---@param dataset string
---@return string|nil
local zfs_mountpoint = function(dataset)
local zfs, _ = Command("zfs"):arg({ "get", "-H", "-o", "value", "mountpoint", dataset }):output()
-- not a dataset!
if not zfs.status.success then
return nil
end
-- legacy mountpoint, search for actual mountpoint using df
if zfs.stdout == "legacy\n" then
local df, _ = Command("df"):output()
if not df.status.success then
return nil
end
for line in df.stdout:gmatch("[^\r\n]+") do
-- match start of line
if string.sub(line, 1, #dataset) == dataset then
local mountpoint = nil
for field in line:gmatch("%S+") do
-- mountpoint is last field in df output
mountpoint = field
end
return mountpoint
end
end
else
return zfs.stdout:gsub("\n$", "")
end
-- shouldn't be here
return nil
end
-- returns the path relative to the mountpoint / snapshot
---@param cwd string
---@param mountpoint string
local zfs_relative = function(cwd, mountpoint)
-- relative path to get mountpoint
local relative = (cwd:sub(0, #mountpoint) == mountpoint) and cwd:sub(#mountpoint + 1) or cwd
-- is a snapshot dir, strip everything after "/snapshot"
if cwd:find(".zfs/snapshot") ~= nil then
local snapshot_pos = cwd:find("/snapshot")
-- everything after the "/snapshot/"
local after = cwd:sub(snapshot_pos + #"/snapshot" + 1)
local first_slash = after:find("/")
-- root of snapshot?
if first_slash == nil then
return "/"
else
return after:sub(first_slash)
end
end
return relative
end
---@class Snapshot
---@field name string
---@field path string
---@param dataset string
---@param mountpoint string
---@param relative string
---@return Snapshot[]
local zfs_snapshots = function(dataset, mountpoint, relative)
-- -S is for reverse order
local zfs_snapshots, _ = Command("zfs"):arg({ "list", "-H", "-t", "snapshot", "-o", "name", "-S", "creation",
dataset })
:output()
if not zfs_snapshots.status.success then
return {}
end
---@type Snapshot[]
local snapshots = {}
for snapshot in zfs_snapshots.stdout:gmatch("[^\r\n]+") do
-- in the format dataset@snapshot
local sep = snapshot:find("@")
local id = snapshot:sub(sep + 1)
table.insert(snapshots, {
id = id,
path = mountpoint .. "/.zfs/snapshot/" .. id .. relative,
})
end
return snapshots
end
---@param cwd string
---@return string|nil
local function btrfs_mountpoint(cwd)
local cmd, _ = Command("findmnt"):arg({ "-no", "TARGET", "-T", cwd }):output()
if not cmd.status.success then
return nil
end
return trim(cmd.stdout)
end
---Returns the current uuid and the parent uuid
---@param cwd string
---@return string|nil, string|nil
local function btrfs_uuids(cwd)
local cmd, _ = run_with_sudo("btrfs", { "subvolume", "show", cwd })
if not cmd then
return nil
end
local parent_uuid = nil
local uuid = nil
for line in cmd.stdout:gmatch("[^\r\n]+") do
local parent_uuid_re = line:match("^%s*Parent UUID:%s*(%S+)")
if parent_uuid_re then
parent_uuid = trim(parent_uuid_re)
end
local uuid_re = line:match("^%s*UUID:%s*(%S+)")
if uuid_re then
uuid = trim(uuid_re)
end
end
return parent_uuid, uuid
end
---@param mountpoint string
---@param current_uuid string
---@param current_parent_uuid string|nil
---@return { snapshots: Snapshot[], latest_path: string, current_snapshot_id: string }
local function btrfs_snapshots(mountpoint, current_uuid, current_parent_uuid)
local snapshots_cmd, _ = run_with_sudo("btrfs", { "subvolume", "list", "-q", "-u", mountpoint })
if not snapshots_cmd then
return {}
end
local snapshots = {}
local latest_path = ""
local current_snapshot_id = ""
for line in snapshots_cmd.stdout:gmatch("[^\r\n]+") do
local pattern = "ID (%d+) gen %d+ top level %d+ parent_uuid ([%w-]+)%s+uuid ([%w-]+) path (%S+)"
-- Extract the fields
local subvol_id, parent_uuid, uuid, name = line:match(pattern)
parent_uuid = trim(parent_uuid)
local path = mountpoint .. "/" .. name
local is_parent = false
if current_parent_uuid == "-" then
if parent_uuid == "-" and uuid == current_uuid then
is_parent = true
end
else
if uuid == current_parent_uuid then
is_parent = true
end
end
if is_parent then
latest_path = path
end
if uuid == current_uuid and not is_parent then
current_snapshot_id = name
end
if not is_parent then
table.insert(snapshots, {
id = name,
subvol_id = subvol_id, -- used only for sorting
path = path,
})
end
end
-- Sort snapshots by time descending
table.sort(snapshots, function(a, b)
return a.subvol_id > b.subvol_id
end)
return { snapshots = snapshots, latest_path = latest_path, current_snapshot_id = current_snapshot_id }
end
return {
entry = function(_, job)
local action = job.arg[1]
local cwd = get_cwd()
if action ~= "exit" and action ~= "prev" and action ~= "next" then
return notify_error("Invalid action: " .. action)
end
local fs_type = get_filesystem_type(cwd)
if fs_type ~= "zfs" and fs_type ~= "btrfs" then
return notify_error("Current directory is not on a BTRFS / ZFS filesystem.")
end
local current_snapshot_id = ""
local latest_path = ""
local snapshots = {}
if fs_type == "zfs" then
local dataset = zfs_dataset(cwd)
if dataset == nil then
return notify_error("Current directory is not within a ZFS dataset.")
end
if cwd:find(".zfs/snapshot") ~= nil then
-- in the format dataset@snapshot
local sep = dataset:find("@")
current_snapshot_id = dataset:sub(sep + 1)
dataset = dataset:sub(1, sep - 1)
end
local mountpoint = zfs_mountpoint(dataset)
if mountpoint == nil then
return notify_error("Current directory is not within a ZFS dataset.")
end
-- NOTE: relative already has leading "/"
local relative = zfs_relative(cwd, mountpoint)
latest_path = mountpoint .. relative
snapshots = zfs_snapshots(dataset, mountpoint, relative)
elseif fs_type == "btrfs" then
local mountpoint = btrfs_mountpoint(cwd)
local parent_uuid, uuid = btrfs_uuids(cwd)
if mountpoint == nil or uuid == nil then
return notify_error("Current directory is not within a BTRFS subvolume.")
end
local ret = btrfs_snapshots(mountpoint, uuid, parent_uuid)
snapshots = ret.snapshots
latest_path = ret.latest_path
current_snapshot_id = ret.current_snapshot_id
end
if action == "exit" then
ya.manager_emit("cd", { latest_path })
return
end
if #snapshots == 0 then
return notify_warn("No snapshots found.")
end
---@param start_idx integer
---@param end_idx integer
---@param step integer
local find_and_goto_snapshot = function(start_idx, end_idx, step)
if start_idx == 0 then
-- going from newest snapshot to current state
return ya.manager_emit("cd", { latest_path })
elseif start_idx < 0 then
return notify_warn("No earlier snapshots found.")
elseif start_idx > #snapshots then
return notify_warn("No earlier snapshots found.")
end
for i = start_idx, end_idx, step do
local snapshot_dir = snapshots[i].path
if io.open(snapshot_dir, "r") then
return ya.manager_emit("cd", { snapshot_dir })
end
end
local direction = action == "prev" and "earlier" or "later"
return notify_warn("No " .. direction .. " snapshots found.")
end
-- NOTE: latest snapshot is first in list
if current_snapshot_id == "" then
if action == "prev" then
-- go to latest snapshot
return find_and_goto_snapshot(1, #snapshots, 1)
elseif action == "next" then
return notify_warn("No later snapshots found.")
end
end
-- has current snapshot
local idx = find_index(snapshots, function(snapshot) return snapshot.id == current_snapshot_id end)
if idx == nil then
return notify_error("Snapshot not found.")
end
if action == "prev" then
find_and_goto_snapshot(idx + 1, #snapshots, 1)
elseif action == "next" then
find_and_goto_snapshot(idx - 1, 1, -1)
end
end,
}

View File

@@ -1,32 +0,0 @@
# toggle-view.yazi
Toggle the different views: parent, current and preview.
## Requirements
- [Yazi](https://github.com/sxyazi/yazi/) v0.4 or later.
## Installation
```sh
ya pack -a dawsers/toggle-view
```
## Usage
Add this to your `~/.config/yazi/keymap.toml`:
``` toml
[manager]
prepend_keymap = [
{ on = "<C-1>", run = "plugin toggle-view --args=parent", desc = "Toggle parent" },
{ on = "<C-2>", run = "plugin toggle-view --args=current", desc = "Toggle current" },
{ on = "<C-3>", run = "plugin toggle-view --args=preview", desc = "Toggle preview" },
]
```
Now each key will toggle on/off one of the three panels: `Ctrl+1` for
*parent*, `Ctrl+2` for *current* and `Ctrl+3` for *preview*.
You can set your own key bindings.

View File

@@ -1,63 +0,0 @@
--- @sync entry
-- Toggle different views on/off: parent, current, preview
local function entry(st, job)
local arg = job.arg or job
local action = arg[1]
if not action then
return
end
if st.view == nil then
st.old_parent = MANAGER.ratio.parent
st.old_current = MANAGER.ratio.current
st.old_preview = MANAGER.ratio.preview
-- Get current tab ratios
local all_old = st.old_parent + st.old_current + st.old_preview
local area = ui.Rect { x= 0, y = 0, w = all_old, h = 10 }
local tab = Tab:new(area, cx.active)
st.parent = tab._chunks[1].w
st.current = tab._chunks[2].w
st.preview = tab._chunks[3].w
st.layout = Tab.layout
st.view = true -- initialized
end
if action == "parent" then
if st.parent > 0 then
st.parent = 0
else
st.parent = st.old_parent
end
elseif action == "current" then
if st.current > 0 then
st.current = 0
else
st.current = st.old_current
end
elseif action == "preview" then
if st.preview > 0 then
st.preview = 0
else
st.preview = st.old_preview
end
else
return
end
Tab.layout = function(self)
local all = st.parent + st.current + st.preview
self._chunks = ui.Layout()
:direction(ui.Layout.HORIZONTAL)
:constraints({
ui.Constraint.Ratio(st.parent, all),
ui.Constraint.Ratio(st.current, all),
ui.Constraint.Ratio(st.preview, all),
})
:split(self._area)
end
ya.app_emit("resize", {})
end
local function enabled(st) return st.view ~= nil end
return { entry = entry, enabled = enabled }

Submodule yazi/.config/yazi/plugins/whoosh.yazi added at 2a55ce4140

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/>.

View File

@@ -0,0 +1,76 @@
# 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({
editor = "nvim", -- Editor command (default: "hx")
args = { "--noplugin" }, -- Additional editor arguments (default: {})
file_arg_format = "+{row} {file}", -- File argument format (default: "{file}:{row}:{col}")
})
```
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 `Ctrl-T` to toggle 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.

View File

@@ -0,0 +1,113 @@
local M = {
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)
function M:setup(opts)
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 cmd_args = [=[
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 "ctrl-t: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 'CTRL-T: 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

View File

@@ -1,112 +0,0 @@
# Yet another bookmarks
A [Yazi](https://github.com/sxyazi/yazi) plugin for bookmark management, supporting the following features
- Persistent bookmarks. No bookmarks are lost after you close yazi.
- Quickly jump, delete, and rename a bookmark by keymap.
- Support fuzzy search through [fzf](https://github.com/junegunn/fzf).
- Configure your bookmarks using Lua language.
## Installation
> [!NOTE]
> Yazi >= 0.25.
```sh
# Linux/macOS
git clone https://github.com/h-hg/yamb.yazi.git ~/.config/yazi/plugins/yamb.yazi
# Windows
git clone https://github.com/h-hg/yamb.yazi.git $env:APPDATA\yazi\config\plugins\yamb.yazi
# if you are using Yazi version >= 3.0
ya pack -a h-hg/yamb
```
## Usage
Add this to your `init.lua`
```lua
-- You can configure your bookmarks by lua language
local bookmarks = {}
local path_sep = package.config:sub(1, 1)
local home_path = ya.target_family() == "windows" and os.getenv("USERPROFILE") or os.getenv("HOME")
if ya.target_family() == "windows" then
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
table.insert(bookmarks, {
tag = "Desktop",
path = home_path .. path_sep .. "Desktop" .. path_sep,
key = "d"
})
require("yamb"):setup {
-- Optional, the path ending with path seperator represents folder.
bookmarks = bookmarks,
-- Optional, recieve notification everytime you jump.
jump_notify = true,
-- Optional, the cli of fzf.
cli = "fzf",
-- Optional, a string used for randomly generating keys, where the preceding characters have higher priority.
keys = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
-- Optional, the path of bookmarks
path = (ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\bookmark") or
(os.getenv("HOME") .. "/.config/yazi/bookmark"),
}
```
Add this to your `keymap.toml`:
```toml
[[manager.prepend_keymap]]
on = [ "u", "a" ]
run = "plugin yamb save"
desc = "Add bookmark"
[[manager.prepend_keymap]]
on = [ "u", "g" ]
run = "plugin yamb jump_by_key"
desc = "Jump bookmark by key"
[[manager.prepend_keymap]]
on = [ "u", "G" ]
run = "plugin yamb jump_by_fzf"
desc = "Jump bookmark by fzf"
[[manager.prepend_keymap]]
on = [ "u", "d" ]
run = "plugin yamb delete_by_key"
desc = "Delete bookmark by key"
[[manager.prepend_keymap]]
on = [ "u", "D" ]
run = "plugin yamb delete_by_fzf"
desc = "Delete bookmark by fzf"
[[manager.prepend_keymap]]
on = [ "u", "A" ]
run = "plugin yamb delete_all"
desc = "Delete all bookmarks"
[[manager.prepend_keymap]]
on = [ "u", "r" ]
run = "plugin yamb rename_by_key"
desc = "Rename bookmark by key"
[[manager.prepend_keymap]]
on = [ "u", "R" ]
run = "plugin yamb rename_by_fzf"
desc = "Rename bookmark by fzf"
```

View File

@@ -1,355 +0,0 @@
local path_sep = package.config:sub(1, 1)
local get_hovered_path = ya.sync(function(state)
local h = cx.active.current.hovered
if h then
local path = tostring(h.url)
if h.cha.is_dir then
return path .. path_sep
end
return path
else
return ''
end
end)
local get_state_attr = ya.sync(function(state, attr)
return state[attr]
end)
local set_state_attr = ya.sync(function(state, attr, value)
state[attr] = value
end)
local set_bookmarks = ya.sync(function(state, path, value)
state.bookmarks[path] = value
end)
local sort_bookmarks = function(bookmarks, key1, key2, reverse)
reverse = reverse or false
table.sort(bookmarks, function(x, y)
if x[key1] == nil and y[key1] == nil then
return x[key2] < y[key2]
elseif x[key1] == nil then
return false
elseif y[key1] == nil then
return true
else
return x[key1] < y[key1]
end
end)
if reverse then
local n = #bookmarks
for i = 1, math.floor(n / 2) do
bookmarks[i], bookmarks[n - i + 1] = bookmarks[n - i + 1], bookmarks[i]
end
end
return bookmarks
end
local save_to_file = function(mb_path, bookmarks)
local file = io.open(mb_path, "w")
if file == nil then
return
end
local array = {}
for _, item in pairs(bookmarks) do
table.insert(array, item)
end
sort_bookmarks(array, "tag", "key", true)
for _, item in ipairs(array) do
file:write(string.format("%s\t%s\t%s\n", item.tag, item.path, item.key))
end
file:close()
end
local fzf_find = function(cli, mb_path)
local permit = ya.hide()
local cmd = string.format("%s < \"%s\"", cli, mb_path)
local handle = io.popen(cmd, "r")
local result = ""
if handle then
-- strip
result = string.gsub(handle:read("*all") or "", "^%s*(.-)%s*$", "%1")
handle:close()
end
permit:drop()
local tag, path, key = string.match(result or "", "(.-)\t(.-)\t(.*)")
return path
end
local which_find = function(bookmarks)
local cands = {}
for path, item in pairs(bookmarks) do
if #item.tag ~= 0 then
table.insert(cands, { desc = item.tag, on = item.key, path = item.path })
end
end
sort_bookmarks(cands, "on", "desc", false)
if #cands == 0 then
ya.notify {
title = "Bookmarks",
content = "Empty bookmarks",
timeout = 2,
level = "info",
}
return nil
end
local idx = ya.which { cands = cands }
if idx == nil then
return nil
end
return cands[idx].path
end
local action_jump = function(bookmarks, path, jump_notify)
if path == nil then
return
end
local tag = bookmarks[path].tag
if string.sub(path, -1) == path_sep then
ya.manager_emit("cd", { path })
else
ya.manager_emit("reveal", { path })
end
if jump_notify then
ya.notify {
title = "Bookmarks",
content = 'Jump to "' .. tag .. '"',
timeout = 2,
level = "info",
}
end
end
local generate_key = function(bookmarks)
local keys = get_state_attr("keys")
local key2rank = get_state_attr("key2rank")
local mb = {}
for _, item in pairs(bookmarks) do
if #item.key == 1 then
table.insert(mb, item.key)
end
end
if #mb == 0 then
return keys[1]
end
table.sort(mb, function(a, b)
return key2rank[a] < key2rank[b]
end)
local idx = 1
for _, key in ipairs(keys) do
if idx > #mb or key2rank[key] < key2rank[mb[idx]] then
return key
end
idx = idx + 1
end
return nil
end
local action_save = function(mb_path, bookmarks, path)
if path == nil or #path == 0 then
return
end
local path_obj = bookmarks[path]
-- check tag
local tag = path_obj and path_obj.tag or path:match(".*[\\/]([^\\/]+)[\\/]?$")
while true do
local value, event = ya.input({
title = "Tag (alias name)",
value = tag,
position = { "top-center", y = 3, w = 40 },
})
if event ~= 1 then
return
end
tag = value or ''
if #tag == 0 then
ya.notify {
title = "Bookmarks",
content = "Empty tag",
timeout = 2,
level = "info",
}
else
-- check the tag
local tag_obj = nil
for _, item in pairs(bookmarks) do
if item.tag == tag then
tag_obj = item
break
end
end
if tag_obj == nil or tag_obj.path == path then
break
end
ya.notify {
title = "Bookmarks",
content = "Duplicated tag",
timeout = 2,
level = "info",
}
end
end
-- check key
local key = path_obj and path_obj.key or generate_key(bookmarks)
while true do
local value, event = ya.input({
title = "Key (1 character, optional)",
value = key,
position = { "top-center", y = 3, w = 40 },
})
if event ~= 1 then
return
end
key = value or ""
if key == "" then
key = ""
break
elseif #key == 1 then
-- check the key
local key_obj = nil
for _, item in pairs(bookmarks) do
if item.key == key then
key_obj = item
break
end
end
if key_obj == nil or key_obj.path == path then
break
else
ya.notify {
title = "Bookmarks",
content = "Duplicated key",
timeout = 2,
level = "info",
}
end
else
ya.notify {
title = "Bookmarks",
content = "The length of key shoule be 1",
timeout = 2,
level = "info",
}
end
end
-- save
set_bookmarks(path, { tag = tag, path = path, key = key })
bookmarks = get_state_attr("bookmarks")
save_to_file(mb_path, bookmarks)
ya.notify {
title = "Bookmarks",
content = '"' .. tag .. '" saved"',
timeout = 2,
level = "info",
}
end
local action_delete = function(mb_path, bookmarks, path)
if path == nil then
return
end
local tag = bookmarks[path].tag
set_bookmarks(path, nil)
bookmarks = get_state_attr("bookmarks")
save_to_file(mb_path, bookmarks)
ya.notify {
title = "Bookmarks",
content = '"' .. tag .. '" deleted',
timeout = 2,
level = "info",
}
end
local action_delete_all = function(mb_path)
local value, event = ya.input({
title = "Delete all bookmarks? (y/n)",
position = { "top-center", y = 3, w = 40 },
})
if event ~= 1 then
return
end
if string.lower(value) == "y" then
set_state_attr("bookmarks", {})
save_to_file(mb_path, {})
ya.notify {
title = "Bookmarks",
content = "All bookmarks deleted",
timeout = 2,
level = "info",
}
else
ya.notify {
title = "Bookmarks",
content = "Cancel delete",
timeout = 2,
level = "info",
}
end
end
return {
setup = function(state, options)
state.path = options.path or
(ya.target_family() == "windows" and os.getenv("APPDATA") .. "\\yazi\\config\\bookmark") or
(os.getenv("HOME") .. "/.config/yazi/bookmark")
state.cli = options.cli or "fzf"
state.jump_notify = options.jump_notify and true
-- init the keys
local keys = options.keys or "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
state.keys = {}
state.key2rank = {}
for i = 1, #keys do
local char = keys:sub(i, i)
table.insert(state.keys, char)
state.key2rank[char] = i
end
-- init the bookmarks
local bookmarks = {}
for _, item in pairs(options.bookmarks or {}) do
bookmarks[item.path] = { tag = item.tag, path = item.path, key = item.key }
end
-- load the config
local file = io.open(state.path, "r")
if file ~= nil then
for line in file:lines() do
local tag, path, key = string.match(line, "(.-)\t(.-)\t(.*)")
if tag and path then
key = key or ""
bookmarks[path] = { tag = tag, path = path, key = key }
end
end
file:close()
end
-- create bookmarks file to enable fzf
save_to_file(state.path, bookmarks)
state.bookmarks = bookmarks
end,
entry = function(self, jobs)
local action = jobs.args[1]
if not action then
return
end
local mb_path, cli, bookmarks, jump_notify = get_state_attr("path"), get_state_attr("cli"), get_state_attr("bookmarks"), get_state_attr("jump_notify")
if action == "save" then
action_save(mb_path, bookmarks, get_hovered_path())
elseif action == "delete_by_key" then
action_delete(mb_path, bookmarks, which_find(bookmarks))
elseif action == "delete_by_fzf" then
action_delete(mb_path, bookmarks, fzf_find(cli, mb_path))
elseif action == "delete_all" then
action_delete_all(mb_path)
elseif action == "jump_by_key" then
action_jump(bookmarks, which_find(bookmarks), jump_notify)
elseif action == "jump_by_fzf" then
action_jump(bookmarks, fzf_find(cli, mb_path), jump_notify)
elseif action == "rename_by_key" then
action_save(mb_path, bookmarks, which_find(bookmarks))
elseif action == "rename_by_fzf" then
action_save(mb_path, bookmarks, fzf_find(cli, mb_path))
end
end,
}

View File

@@ -2,39 +2,62 @@
Simple lualine-like status line for yazi.
Read more about features and configuration [here](#features).
![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)
> ⚠️ **Note**:
> If you experience any issues after updating, please refer to the latest release notes. This repository is continuously synced with the upstream Yazi source code, which is actively maintained and frequently updated.
![preview](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/preview.png)
All supported features are listed [here](#features). More presets are available [here](#presets).
## Requirements
- yazi version >= [25.4.8](https://github.com/sxyazi/yazi/releases/tag/v25.4.8)
- yazi version >= [917e1f5](https://github.com/sxyazi/yazi/commit/917e1f54a10445f2e25147c4b81a3c77d8233632)
- 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.2](https://github.com/llanosrocas/yaziline.yazi/releases/tag/v2.5.2) | [v25.12.29](https://github.com/sxyazi/yazi/releases/tag/v25.12.29) |
| [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 pack -a llanosrocas/yaziline
ya pkg add llanosrocas/yaziline
```
Or manually copy `init.lua` to the `~/.config/yazi/plugins/yaziline.yazi/init.lua`
_Or manually copy `main.lua` to the `~/.config/yazi/plugins/yaziline.yazi/main.lua`_
## Usage
Add this to your `~/.config/yazi/init.lua`:
2. Add this line to your `~/.config/yazi/init.lua`:
```lua
require("yaziline"):setup()
```
Optionally, configure line:
## Configuration
This is default config, if you want to see presets go to [this section](#presets).
```lua
require("yaziline"):setup({
color = "#98c379", -- main theme color
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",
@@ -53,79 +76,44 @@ require("yaziline"):setup({
filename_max_length = 24, -- truncate when filename > 24
filename_truncate_length = 6, -- leave 6 chars on both sides
filename_truncate_separator = "..." -- the separator of the truncated filename
filename_truncate_separator = "..."
})
```
By default yaziline uses color values from your `theme.toml`:
- mode and position font color: th.which.mask.bg
- default_files_color: which.separator_style.fg
- 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
### Preconfigured separators
Choose your style:
### Presets
- `angly`
![angly](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/angly.png)
![angly](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/angly.png)
- `curvy`
![curvy](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/curvy.png)
![curvy](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/curvy.png)
- `liney`
![liney](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/liney.png)
![liney](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/liney.png)
- `empty`
![empty](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/empty.png)
### Separator customization
You can provide your own symbols for separators combined with preconfigured separators. For example:
```lua
require("yaziline"):setup({
-- Optinal config
separator_style = "angly", -- preconfigured style
separator_open = "", -- instead of 
separator_close = "", -- instead of 
separator_open_thin = "", -- change to anything
separator_close_thin = "", -- change to anything
separator_head = "", -- to match the style
separator_tail = "" -- to match the style
})
```
![empty](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/separator-combination.png)
_You can find more symbols [here](https://www.nerdfonts.com/cheat-sheet)_
### File actions icons
You can provide your own symbols for `select` and `yank`. For example:
```lua
require("yaziline"):setup({
-- Optinal config
select_symbol = "", -- "S" by default
yank_symbol = "󰆐" -- "Y" by default
})
```
![empty](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/file-actions.png)
_You can find more symbols [here](https://www.nerdfonts.com/cheat-sheet)_
### Colors and font weight
By default yaziline uses color values from your `theme.toml` (or flavor) but you can set custom colors in the `init.lua`:
```lua
require("yaziline"):setup({
color = "#98c379",
default_files_color = "darkgray",
selected_files_color = "white",
yanked_files_color = "green",
cut_files_color = "red",
})
```
For example, here is how my line looks like:
![preview-2](https://github.com/llanosrocas/yaziline.yazi/blob/master/.github/images/preview-2.png)
![empty](https://github.com/llanosrocas/yaziline.yazi/blob/main/.github/images/empty.png)
### Selected and Yanked Counter
@@ -137,9 +125,9 @@ Displays the truncated filename on the left, which is useful for smaller windows
```lua
require("yaziline"):setup({
filename_max_length = 24, -- truncate when filename > 24
filename_truncate_length = 6, -- leave 6 chars on both sides
filename_truncate_separator = "..." -- the separator of the truncated filename
filename_max_length = 24,
filename_truncate_length = 6,
filename_truncate_separator = "..."
})
```

View File

@@ -1,199 +1,212 @@
---@diagnostic disable: undefined-global
local function setup(_, options)
options = options or {}
options = options or {}
local default_separators = {
angly = { "", "", "", "" },
curvy = { "", "", "", "" },
liney = { "", "", "|", "|" },
empty = { "", "", "", "" },
}
local separators = default_separators[options.separator_style or "angly"]
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",
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 "...",
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,
color = options.color or nil,
secondary_color = options.secondary_color or nil,
default_files_color = options.default_files_color
or th.which.separator_style.fg
or "darkgray",
or th.which.separator_style:fg()
or "darkgray",
selected_files_color = options.selected_files_color
or th.mgr.count_selected.bg
or "white",
or th.mgr.count_selected:bg()
or "white",
yanked_files_color = options.selected_files_color
or th.mgr.count_copied.bg
or "green",
or th.mgr.count_copied:bg()
or "green",
cut_files_color = options.cut_files_color
or th.mgr.count_cut.bg
or "red",
}
or th.mgr.count_cut:bg()
or "red",
}
local current_separator_style = config.separator_styles
local current_separator_style = config.separator_styles
function Header:count()
return ui.Line({})
end
function Header:count()
return ui.Line({})
end
function Status:mode()
local mode = tostring(self._tab.mode):upper()
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(th.which.mask.bg)
:bg(config.color or style.main.bg),
})
end
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(th.which.mask:bg())
:bg(config.color or style.main:bg()),
})
end
function Status:size()
local h = self._current.hovered
local size = h and ya.readable_size(h:size() or h.cha.len)
local style = self:style()
return ui.Span(current_separator_style.separator_close .. " " .. size .. " ")
:fg(config.color or style.main.bg)
:bg(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()
function Status:size()
local h = self._current.hovered
if not h then
local size = h and (h:size() or h.cha.len) or 0
local style = self:style()
return ui.Span(current_separator_style.separator_close .. " " .. ya.readable_size(size) .. " ")
: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)
local style = self:style()
return ui.Line {
return ui.Line({
ui.Span(current_separator_style.separator_close .. " ")
:fg(th.which.separator_style.fg),
:fg(config.secondary_color or th.which.separator_style:fg()),
ui.Span(truncated_name)
:fg(config.color or style.main.bg),
}
: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
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 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"
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(th.which.separator_style.fg),
ui.Span(config.select_symbol .. " " .. files_selected .. " ")
:fg(selected_fg),
ui.Span(yanked_text .. " ")
:fg(yanked_fg),
})
end
return ui.Line({
ui.Span(" " .. current_separator_style.separator_close_thin .. " ")
:fg(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
local cha = hovered.cha
local time = (cha.mtime or 0) // 1
function Status:modified()
local hovered = cx.active.current.hovered
return ui.Span(os.date("%Y-%m-%d %H:%M", time) .. " " .. current_separator_style.separator_open_thin .. " ")
:fg(th.which.separator_style.fg)
end
if not hovered then
return ""
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
local cha = hovered.cha
local time = (cha.mtime or 0) // 1
if percent == 0 then
percent = " Top "
elseif percent == 100 then
percent = " Bot "
else
percent = string.format(" %2d%% ", percent)
end
return ui.Span(os.date("%Y-%m-%d %H:%M", time) .. " " .. current_separator_style.separator_open_thin .. " ")
:fg(th.which.separator_style:fg())
end
local style = self:style()
return ui.Line({
ui.Span(" " .. current_separator_style.separator_open)
:fg(th.which.separator_style.fg),
ui.Span(percent)
:fg(config.color or style.main.bg)
:bg(th.which.separator_style.fg),
ui.Span(current_separator_style.separator_open)
:fg(config.color or style.main.bg)
:bg(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
function Status:position()
local cursor = self._tab.current.cursor
local length = #self._tab.current.files
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(string.format(" %2d/%-2d ", math.min(cursor + 1, length), length))
:fg(th.which.mask.bg)
:bg(config.color or style.main.bg),
ui.Span(current_separator_style.separator_tail):fg(config.color or style.main.bg),
})
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
Status:children_add(Status.files, 4000, Status.LEFT)
Status:children_add(Status.modified, 0, Status.RIGHT)
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(th.which.mask:bg())
: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 }
return { setup = setup }

View File

@@ -1,4 +0,0 @@
[flavor]
dark = "catppuccin-mocha"
light = "catppuccin-mocha"

View File

@@ -1,116 +1,65 @@
## https://www.youtube.com/watch?v=iKb3cHDD9hw# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
"$schema" = "https://yazi-rs.github.io/schemas/yazi.json"
[mgr]
ratio = [ 2, 3, 5 ]
sort_by = "alphabetical"
ratio = [2, 3, 5]
sort_by = "natural"
sort_sensitive = false
sort_reverse = false
sort_reverse = false
sort_dir_first = true
sort_translit = false
linemode = "none"
show_hidden = true
show_symlink = true
scrolloff = 5
mouse_events = [ "click", "scroll" ]
title_format = "Yazi: {cwd}"
[preview]
wrap = "no"
tab_size = 2
max_width = 2400
max_height = 2000
cache_dir = ""
image_delay = 30
image_filter = "triangle"
image_quality = 75
sixel_fraction = 15
ueberzug_scale = 1
ueberzug_offset = [ 0, 0, 0, 0 ]
tab_size = 2
max_width = 600
max_height = 900
cache_dir = ""
image_delay = 30
image_filter = "triangle"
image_quality = 75
[opener]
edit = [
{ run = 'nvim $0', block = true, desc = "nvim", for = "unix" },
{ run = 'code %*', orphan = true, desc = "code", for = "windows" },
{ run = 'code -w %*', block = true, desc = "code (block)", for = "windows" },
{ run = 'nvim "$@"', block = true, desc = "nvim", for = "unix" },
]
open = [
{ run = 'xdg-open "$1"', desc = "Open", for = "linux" },
{ run = 'open "$@"', desc = "Open", for = "macos" },
{ run = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" },
{ run = 'xdg-open "$1"', desc = "Open", for = "linux" },
]
reveal = [
{ run = 'xdg-open "$(dirname "$1")"', desc = "Reveal", for = "linux" },
{ run = 'open -R "$1"', desc = "Reveal", for = "macos" },
{ run = 'explorer /select,"%1"', orphan = true, desc = "Reveal", for = "windows" },
{ run = '''exiftool "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show EXIF", for = "unix" },
]
extract = [
{ run = 'ouch d -y "%*"', desc = "Extract here with ouch", for = "windows" },
{ run = 'ouch d -y "$@"', desc = "Extract here with ouch", for = "unix" },
# { run = 'ya pub extract --list "$@"', desc = "Extract here", for = "unix" },
#{ run = 'ya pub extract --list %*', desc = "Extract here", for = "windows" },
{ run = 'xdg-open "$(dirname "$1")"', desc = "Reveal", for = "linux" },
]
play = [
{ run = 'mpv --force-window "$@"', orphan = true, for = "unix" },
{ run = 'mpv --force-window %*', orphan = true, for = "windows" },
{ run = '''mediainfo "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show media info", for = "unix" },
]
[open]
rules = [
# Folder
{ name = "*/", use = [ "edit", "open", "reveal" ] },
# Text
{ mime = "text/*", use = [ "edit", "reveal" ] },
# Image
{ mime = "image/*", use = [ "open", "reveal" ] },
# Media
# { mime = "{audio,video}/*", use = [ "play", "reveal" ] },
# Archive
{ mime = "application/{zip,rar,7z*,tar,gzip,xz,zstd,bzip*,lzma,compress,archive,cpio,arj,xar,ms-cab*}", use = [ "extract", "reveal" ] },
# JSON
{ mime = "application/{json,ndjson}", use = [ "edit", "reveal" ] },
{ mime = "*/javascript", use = [ "edit", "reveal" ] },
# Empty file
{ mime = "inode/empty", use = [ "edit", "reveal" ] },
# Fallback
{ name = "*", use = [ "open", "reveal" ] },
{ mime = "text/*", use = "edit" },
{ mime = "image/*", use = "open" },
{ mime = "video/*", use = "open" },
{ mime = "audio/*", use = "open" },
{ mime = "application/pdf", use = "open" },
{ mime = "*", use = "open" },
]
[tasks]
micro_workers = 10
macro_workers = 10
bizarre_retry = 3
image_alloc = 536870912 # 512MB
image_bound = [ 0, 0 ]
suppress_preload = true
macro_workers = 25
bizarre_retry = 5
suppress_preload = false
[plugin]
#fetchers = [
# # Mimetype
# { id = "mime", name = "*", run = "mime", if = "!mime", prio = "high" },
# ]
prepend_fetchers = [
# git plugin
{ id = "git", name = "*", run = "git" },
{ id = "git", name = "*/", run = "git" },
{ id = "mime", mime = "*", run = "mime", prio = "low" },
]
spotters = [
{ name = "*/", run = "folder" },
# Code
{ mime = "text/*", run = "code" },
{ mime = "*/{xml,javascript,wine-extension-ini}", run = "code" },
# Image
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
{ mime = "image/*", run = "image" },
# Video
#{ mime = "video/*", run = "video" },
# Fallback
{ name = "*", run = "file" },
# mime plugin
{ id = "mime", url = "*", run = "mime-ext", prio = "high"},
{ id = "simple-tag", url = "*", run = "simple-tag" },
{ id = "simple-tag", url = "*/", run = "simple-tag" },
]
preloaders = [
# Image
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
@@ -123,6 +72,15 @@ preloaders = [
{ mime = "font/*", run = "font" },
{ mime = "application/ms-opentype", run = "font" },
]
prepend_preloaders = [
# Replace magick, image, video with mediainfo
{ mime = "{audio,video,image}/*", run = "mediainfo" },
{ mime = "application/subrip", run = "mediainfo" },
# Adobe Illustrator, Adobe Photoshop is image/adobe.photoshop, already handled above
{ mime = "application/postscript", run = "mediainfo" },
]
previewers = [
{ name = "*/", run = "folder", sync = true },
# Code
@@ -137,114 +95,24 @@ previewers = [
#{ mime = "video/*", run = "video" },
# PDF
{ mime = "application/pdf", run = "pdf" },
# Archive
{ mime = "application/{zip,rar,7z*,tar,gzip,xz,zstd,bzip*,lzma,compress,archive,cpio,arj,xar,ms-cab*}", run = "archive" },
{ mime = "application/{debian*-package,redhat-package-manager,rpm,android.package-archive}", run = "archive" },
{ name = "*.{AppImage,appimage}", run = "archive" },
# Virtual Disk / Disk Image
{ mime = "application/{iso9660-image,qemu-disk,ms-wim,apple-diskimage}", run = "archive" },
{ mime = "application/virtualbox-{vhd,vhdx}", run = "archive" },
{ name = "*.{img,fat,ext,ext2,ext3,ext4,squashfs,ntfs,hfs,hfsx}", run = "archive" },
# Font
{ mime = "font/*", run = "font" },
{ mime = "application/ms-opentype", run = "font" },
# Empty file
{ mime = "inode/empty", run = "empty" },
# Fallback
{ name = "*", run = "file" },
]
# eza-preview
prepend_previewers = [
{ name = "*/", run = "eza-preview"},
# jupyter preview
{ name = "*.ipynb", run = "nbpreview" },
# mediainfo
# { mime = "{image,audio,video}/*", run = "mediainfo-nightly"},
# { mime = "application/subrip", run = "mediainfo-nightly"},
# Archive previewer https://github.com/ndtoan96/ouch.yazi
{ mime = "application/*zip", run = "ouch" },
{ mime = "application/x-tar", run = "ouch" },
{ mime = "application/x-bzip2", run = "ouch" },
{ mime = "application/x-7z-compressed", run = "ouch" },
{ mime = "application/x-rar", run = "ouch" },
{ mime = "application/x-xz", run = "ouch" },
# rich preview https://github.com/AnirudhG07/rich-preview.yazi
{ name = "*.csv", run = "rich-preview"}, # for csv files
{ name = "*.md", run = "rich-preview" }, # for markdown (.md) files
{ name = "*.rst", run = "rich-preview"}, # for restructured text (.rst) files
{ name = "*.ipynb", run = "rich-preview"}, # for jupyter notebooks (.ipynb)
{ name = "*.json", run = "rich-preview"}, # for json (.json) files
{ name = "*.lang_type", run = "rich-preview"}, # for particular language files eg. .py, .go., .lua, etc.
# mediainfo MUST come before the catch-all piper rule
{ mime = "{audio,video,image}/*", run = "mediainfo"},
{ mime = "application/subrip", run = "mediainfo" },
{ mime = "application/postscript", run = "mediainfo" },
# ouch plugin for archives
{ mime = "application/{*zip,tar,bzip2,7z*,rar,xz,zstd,java-archive}", run = "ouch"},
# piper for directories
{ url = "*/", run = 'piper -- eza -TL=3 --color=always --icons=always --group-directories-first --no-quotes "$1"'},
# piper markdown (commented out as you had it)
# rich preview plugin
{ url = "*.csv", run = "rich-preview"}, # for csv files
{ url = "*.md", run = "rich-preview" }, # for markdown (.md) files
{ url = "*.rst", run = "rich-preview"}, # for restructured text (.rst) files
{ url = "*.ipynb", run = "rich-preview"}, # for jupyter notebooks (.ipynb)
{ url = "*.json", run = "rich-preview"}, # for json (.json) files
# { url = "*.lang_type", run = "rich-preview"} # for particular language files eg. .py, .go., .lua, etc.
]
[input]
cursor_blink = false
# cd
cd_title = "Change directory:"
cd_origin = "top-center"
cd_offset = [ 0, 2, 50, 3 ]
# create
create_title = [ "Create:", "Create (dir):" ]
create_origin = "top-center"
create_offset = [ 0, 2, 50, 3 ]
# rename
rename_title = "Rename:"
rename_origin = "hovered"
rename_offset = [ 0, 1, 50, 3 ]
# filter
filter_title = "Filter:"
filter_origin = "top-center"
filter_offset = [ 0, 2, 50, 3 ]
# find
find_title = [ "Find next:", "Find previous:" ]
find_origin = "top-center"
find_offset = [ 0, 2, 50, 3 ]
# search
search_title = "Search via {n}:"
search_origin = "top-center"
search_offset = [ 0, 2, 50, 3 ]
# shell
shell_title = [ "Shell:", "Shell (block):" ]
shell_origin = "top-center"
shell_offset = [ 0, 2, 50, 3 ]
[confirm]
# trash
trash_title = "Trash {n} selected file{s}?"
trash_origin = "center"
trash_offset = [ 0, 0, 70, 20 ]
# delete
delete_title = "Permanently delete {n} selected file{s}?"
delete_origin = "center"
delete_offset = [ 0, 0, 70, 20 ]
# overwrite
overwrite_title = "Overwrite file?"
overwrite_content = "Will overwrite the following file:"
overwrite_origin = "center"
overwrite_offset = [ 0, 0, 50, 15 ]
# quit
quit_title = "Quit?"
quit_content = "The following task is still running, are you sure you want to quit?"
quit_origin = "center"
quit_offset = [ 0, 0, 50, 15 ]
[pick]
open_title = "Open with:"
open_origin = "hovered"
open_offset = [ 0, 1, 50, 7 ]
[which]
sort_by = "none"
sort_sensitive = false
sort_reverse = false
sort_translit = false

View File

@@ -4,6 +4,17 @@ alias neo='neofetch'
alias f='fuck'
alias a='aerc'
# Scripts
alias ar='/mnt/tank/scripts/aria.sh'
alias sp='/mnt/tank/scripts/split.sh'
alias nt='/mnt/tank/scripts/nothumb.sh'
alias nn='/mnt/tank/scripts/nonum.sh'
alias rt='/mnt/tank/scripts/retag.sh'
alias ea='/mnt/tank/scripts/extraudio.sh'
alias dd='/mnt/tank/scripts/m3u8.sh'
alias th='/mnt/tank/scripts/thumb.sh'
alias bwf='/home/liph/scripts/bw-fzf.sh'
# put everything on nvim
alias nano='nvim'
alias vim='nvim'
@@ -136,15 +147,26 @@ alias sysen='sudo systemctl enable'
alias sysst='sudo systemctl start'
# podmand
alias pops='podman ps'
alias pos='podman start'
alias post='podman stop'
alias poc='podman-compose up -d'
alias pocp='podman-compose pull'
alias pocf='podman-compose up -d --force-recreate'
alias porm='podman rm'
alias pormf='podman rm -f'
alias pormi='podman rmi'
alias pops='sudo podman ps'
alias pos='sudo podman start'
alias post='sudo podman stop'
alias poc='sudo podman-compose up -d'
alias pocp='sudo podman-compose pull'
alias pocf='sudo podman-compose up -d --force-recreate'
alias pocst='sudo podman-compose stop'
alias pocs='sudo podman-compose start'
alias pocrs='sudo podman-compose restart'
alias porm='sudo podman rm'
alias pormf='sudo podman rm -f'
alias pormi='sudo podman rmi'
alias pors='sudo podman restart'
alias pol='sudo podman logs'
alias poi='sudo podman images'
alias pocd='sudo podman-compose down'
alias pocdf='pocd && pocf'
alias pocup='pocp && poc'
alias pocupf='pocp && pocf'
alias pocdupd='pocst && pocd && pocp && poc'
# disk space
alias dfh='df -h' # shows a list of all mounted drives

View File

@@ -35,3 +35,7 @@ export QT_QPA_PLATFORM=wayland
export SDL_VIDEODRIVER=wayland
export CLUTTER_BACKEND=wayland
export MOZ_ENABLE_WAYLAND=1
# Bitwarde
# export BW_SESSION=$(bw unlock --raw)