added everythig
This commit is contained in:
17
yazi/.config/yazi/bookmark
Normal file
17
yazi/.config/yazi/bookmark
Normal file
@@ -0,0 +1,17 @@
|
||||
tank /mnt/tank/ t
|
||||
ssd2 /mnt/ssd2/ 7
|
||||
ssd1 /mnt/ssd1/ 6
|
||||
plugins /home/liph/.config/nvim/lua/plugins/ p
|
||||
nvim /home/liph/.config/nvim/ n
|
||||
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
|
||||
Desktop /home/liph/Desktop/ d
|
||||
.config /home/liph/.config/ c
|
||||
21
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/LICENSE
Normal file
21
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/LICENSE
Normal 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.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Himanshu
|
||||
|
||||
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.
|
||||
38
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/README.md
Normal file
38
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
<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.
|
||||
173
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/flavor.toml
Normal file
173
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/flavor.toml
Normal file
@@ -0,0 +1,173 @@
|
||||
# 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" }
|
||||
]
|
||||
|
||||
# : }}}
|
||||
BIN
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/preview.png
Normal file
BIN
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/preview.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 660 KiB |
2021
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/tmtheme.xml
Normal file
2021
yazi/.config/yazi/flavors/catppuccin-mocha.yazi/tmtheme.xml
Normal file
File diff suppressed because it is too large
Load Diff
87
yazi/.config/yazi/init.lua
Normal file
87
yazi/.config/yazi/init.lua
Normal file
@@ -0,0 +1,87 @@
|
||||
require("yaziline"):setup({
|
||||
color = "#98c379", -- main theme color
|
||||
default_files_color = "darkgray", -- color of the file counter when it's inactive
|
||||
selected_files_color = "white",
|
||||
yanked_files_color = "green",
|
||||
cut_files_color = "red",
|
||||
|
||||
separator_style = "angly", -- "angly" | "curvy" | "liney" | "empty"
|
||||
separator_open = "",
|
||||
separator_close = "",
|
||||
separator_open_thin = "",
|
||||
separator_close_thin = "",
|
||||
separator_head = "",
|
||||
separator_tail = "",
|
||||
|
||||
select_symbol = "",
|
||||
yank_symbol = "",
|
||||
|
||||
filename_max_length = 24, -- truncate when filename > 24
|
||||
filename_truncate_length = 6, -- leave 6 chars on both sides
|
||||
filename_truncate_separator = "..." -- the separator of the truncated filename
|
||||
})
|
||||
|
||||
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
|
||||
-- })
|
||||
|
||||
385
yazi/.config/yazi/keymap.toml
Normal file
385
yazi/.config/yazi/keymap.toml
Normal file
@@ -0,0 +1,385 @@
|
||||
# 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" },
|
||||
]
|
||||
|
||||
|
||||
[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" },
|
||||
]
|
||||
|
||||
[spot]
|
||||
|
||||
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" },
|
||||
]
|
||||
|
||||
[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" },
|
||||
]
|
||||
|
||||
[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" },
|
||||
]
|
||||
|
||||
[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" },
|
||||
]
|
||||
54
yazi/.config/yazi/package.toml
Normal file
54
yazi/.config/yazi/package.toml
Normal file
@@ -0,0 +1,54 @@
|
||||
[[plugin.deps]]
|
||||
use = "ahkohd/eza-preview"
|
||||
rev = "5ef05bc"
|
||||
hash = "72355a6c8b7c8de6ed4dda0f98f86fee"
|
||||
|
||||
[[plugin.deps]]
|
||||
use = "iynaix/time-travel"
|
||||
rev = "85baafd"
|
||||
hash = "653fca8253e8cc431e7b1ceacc53ccfc"
|
||||
|
||||
[[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"
|
||||
|
||||
[[plugin.deps]]
|
||||
use = "yazi-rs/plugins:mount"
|
||||
rev = "5eea960"
|
||||
hash = "b3f1d6ec3721d4061aad5f69cddb0cf9"
|
||||
|
||||
[[flavor.deps]]
|
||||
use = "yazi-rs/flavors:catppuccin-mocha"
|
||||
rev = "fc8eeaa"
|
||||
hash = "407710c2af9621a8351453e637d6c870"
|
||||
Submodule yazi/.config/yazi/plugins/PPDATAyaziconfigpluginsfg.yazi added at c201a3e1c0
21
yazi/.config/yazi/plugins/chmod.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/chmod.yazi/LICENSE
Normal 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.
|
||||
28
yazi/.config/yazi/plugins/chmod.yazi/README.md
Normal file
28
yazi/.config/yazi/plugins/chmod.yazi/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
# 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.
|
||||
39
yazi/.config/yazi/plugins/chmod.yazi/main.lua
Normal file
39
yazi/.config/yazi/plugins/chmod.yazi/main.lua
Normal file
@@ -0,0 +1,39 @@
|
||||
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,
|
||||
}
|
||||
21
yazi/.config/yazi/plugins/exifaudio.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/exifaudio.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Sonico98
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
38
yazi/.config/yazi/plugins/exifaudio.yazi/README.md
Normal file
38
yazi/.config/yazi/plugins/exifaudio.yazi/README.md
Normal file
@@ -0,0 +1,38 @@
|
||||
# exifaudio.yazi
|
||||
|
||||
Preview audio metadata and cover on [Yazi](https://github.com/sxyazi/yazi).
|
||||
|
||||

|
||||
|
||||
## 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.
|
||||
231
yazi/.config/yazi/plugins/exifaudio.yazi/main.lua
Normal file
231
yazi/.config/yazi/plugins/exifaudio.yazi/main.lua
Normal file
@@ -0,0 +1,231 @@
|
||||
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
|
||||
21
yazi/.config/yazi/plugins/eza-preview.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/eza-preview.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
63
yazi/.config/yazi/plugins/eza-preview.yazi/README.md
Normal file
63
yazi/.config/yazi/plugins/eza-preview.yazi/README.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# 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:
|
||||

|
||||
|
||||
Tree mode:
|
||||

|
||||
|
||||
## 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({})
|
||||
|
||||
```
|
||||
157
yazi/.config/yazi/plugins/eza-preview.yazi/main.lua
Normal file
157
yazi/.config/yazi/plugins/eza-preview.yazi/main.lua
Normal file
@@ -0,0 +1,157 @@
|
||||
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
|
||||
1
yazi/.config/yazi/plugins/fg.yazi
Submodule
1
yazi/.config/yazi/plugins/fg.yazi
Submodule
Submodule yazi/.config/yazi/plugins/fg.yazi added at c201a3e1c0
1
yazi/.config/yazi/plugins/git.yazi/LICENSE
Symbolic link
1
yazi/.config/yazi/plugins/git.yazi/LICENSE
Symbolic link
@@ -0,0 +1 @@
|
||||
../LICENSE
|
||||
78
yazi/.config/yazi/plugins/git.yazi/README.md
Normal file
78
yazi/.config/yazi/plugins/git.yazi/README.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# git.yazi
|
||||
|
||||
Show the status of Git file changes as linemode in the file list.
|
||||
|
||||
https://github.com/user-attachments/assets/34976be9-a871-4ffe-9d5a-c4cdd0bf4576
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pkg add yazi-rs/plugins:git
|
||||
```
|
||||
|
||||
## Setup
|
||||
|
||||
Add the following to your `~/.config/yazi/init.lua`:
|
||||
|
||||
```lua
|
||||
require("git"):setup()
|
||||
```
|
||||
|
||||
And register it as fetchers in your `~/.config/yazi/yazi.toml`:
|
||||
|
||||
```toml
|
||||
[[plugin.prepend_fetchers]]
|
||||
id = "git"
|
||||
name = "*"
|
||||
run = "git"
|
||||
|
||||
[[plugin.prepend_fetchers]]
|
||||
id = "git"
|
||||
name = "*/"
|
||||
run = "git"
|
||||
```
|
||||
|
||||
## Advanced
|
||||
|
||||
> [!NOTE]
|
||||
> 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:
|
||||
|
||||
- `th.git.modified`
|
||||
- `th.git.added`
|
||||
- `th.git.untracked`
|
||||
- `th.git.ignored`
|
||||
- `th.git.deleted`
|
||||
- `th.git.updated`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
th.git = th.git or {}
|
||||
th.git.modified = ui.Style():fg("blue")
|
||||
th.git.deleted = ui.Style():fg("red"):bold()
|
||||
```
|
||||
|
||||
You can also customize the text of the status sign with:
|
||||
|
||||
- `th.git.modified_sign`
|
||||
- `th.git.added_sign`
|
||||
- `th.git.untracked_sign`
|
||||
- `th.git.ignored_sign`
|
||||
- `th.git.deleted_sign`
|
||||
- `th.git.updated_sign`
|
||||
|
||||
For example:
|
||||
|
||||
```lua
|
||||
-- ~/.config/yazi/init.lua
|
||||
th.git = th.git or {}
|
||||
th.git.modified_sign = "M"
|
||||
th.git.deleted_sign = "D"
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
261
yazi/.config/yazi/plugins/git.yazi/main.lua
Normal file
261
yazi/.config/yazi/plugins/git.yazi/main.lua
Normal file
@@ -0,0 +1,261 @@
|
||||
--- @since 25.5.31
|
||||
|
||||
local WINDOWS = ya.target_family() == "windows"
|
||||
|
||||
-- The code of supported git status,
|
||||
-- also used to determine which status to show for directories when they contain different statuses
|
||||
-- see `bubble_up`
|
||||
---@enum CODES
|
||||
local CODES = {
|
||||
excluded = 100, -- ignored directory
|
||||
ignored = 6, -- ignored file
|
||||
untracked = 5,
|
||||
modified = 4,
|
||||
added = 3,
|
||||
deleted = 2,
|
||||
updated = 1,
|
||||
unknown = 0,
|
||||
}
|
||||
|
||||
local PATTERNS = {
|
||||
{ "!$", CODES.ignored },
|
||||
{ "?$", CODES.untracked },
|
||||
{ "[MT]", CODES.modified },
|
||||
{ "[AC]", CODES.added },
|
||||
{ "D", CODES.deleted },
|
||||
{ "U", CODES.updated },
|
||||
{ "[AD][AD]", CODES.updated },
|
||||
}
|
||||
|
||||
---@param line string
|
||||
---@return CODES, string
|
||||
local function match(line)
|
||||
local signs = line:sub(1, 2)
|
||||
for _, p in ipairs(PATTERNS) do
|
||||
local path, pattern, code = nil, p[1], p[2]
|
||||
if signs:find(pattern) then
|
||||
path = line:sub(4, 4) == '"' and line:sub(5, -2) or line:sub(4)
|
||||
path = WINDOWS and path:gsub("/", "\\") or path
|
||||
end
|
||||
if not path then
|
||||
elseif path:find("[/\\]$") then
|
||||
-- Mark the ignored directory as `excluded`, so we can process it further within `propagate_down`
|
||||
return code == CODES.ignored and CODES.excluded or code, path:sub(1, -2)
|
||||
else
|
||||
return code, path
|
||||
end
|
||||
---@diagnostic disable-next-line: missing-return
|
||||
end
|
||||
end
|
||||
|
||||
---@param cwd Url
|
||||
---@return string?
|
||||
local function root(cwd)
|
||||
local is_worktree = function(url)
|
||||
local file, head = io.open(tostring(url)), nil
|
||||
if file then
|
||||
head = file:read(8)
|
||||
file:close()
|
||||
end
|
||||
return head == "gitdir: "
|
||||
end
|
||||
|
||||
repeat
|
||||
local next = cwd:join(".git")
|
||||
local cha = fs.cha(next)
|
||||
if cha and (cha.is_dir or is_worktree(next)) then
|
||||
return tostring(cwd)
|
||||
end
|
||||
cwd = cwd.parent
|
||||
until not cwd
|
||||
end
|
||||
|
||||
---@param changed Changes
|
||||
---@return Changes
|
||||
local function bubble_up(changed)
|
||||
local new, empty = {}, Url("")
|
||||
for path, code in pairs(changed) do
|
||||
if code ~= CODES.ignored then
|
||||
local url = Url(path).parent
|
||||
while url and url ~= empty do
|
||||
local s = tostring(url)
|
||||
new[s] = (new[s] or CODES.unknown) > code and new[s] or code
|
||||
url = url.parent
|
||||
end
|
||||
end
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
---@param excluded string[]
|
||||
---@param cwd Url
|
||||
---@param repo Url
|
||||
---@return Changes
|
||||
local function propagate_down(excluded, cwd, repo)
|
||||
local new, rel = {}, cwd:strip_prefix(repo)
|
||||
for _, path in ipairs(excluded) do
|
||||
if rel:starts_with(path) then
|
||||
-- If `cwd` is a subdirectory of an excluded directory, also mark it as `excluded`
|
||||
new[tostring(cwd)] = CODES.excluded
|
||||
elseif cwd == repo:join(path).parent then
|
||||
-- If `path` is a direct subdirectory of `cwd`, mark it as `ignored`
|
||||
new[path] = CODES.ignored
|
||||
else
|
||||
-- Skipping, we only care about `cwd` itself and its direct subdirectories for maximum performance
|
||||
end
|
||||
end
|
||||
return new
|
||||
end
|
||||
|
||||
---@param cwd string
|
||||
---@param repo string
|
||||
---@param changed Changes
|
||||
local add = ya.sync(function(st, cwd, repo, changed)
|
||||
---@cast st State
|
||||
|
||||
st.dirs[cwd] = repo
|
||||
st.repos[repo] = st.repos[repo] or {}
|
||||
for path, code in pairs(changed) do
|
||||
if code == CODES.unknown then
|
||||
st.repos[repo][path] = nil
|
||||
elseif code == CODES.excluded then
|
||||
-- Mark the directory with a special value `excluded` so that it can be distinguished during UI rendering
|
||||
st.dirs[path] = CODES.excluded
|
||||
else
|
||||
st.repos[repo][path] = code
|
||||
end
|
||||
end
|
||||
-- TODO: remove this
|
||||
if ui.render then
|
||||
ui.render()
|
||||
else
|
||||
ya.render()
|
||||
end
|
||||
end)
|
||||
|
||||
---@param cwd string
|
||||
local remove = ya.sync(function(st, cwd)
|
||||
---@cast st State
|
||||
|
||||
local repo = st.dirs[cwd]
|
||||
if not repo then
|
||||
return
|
||||
end
|
||||
|
||||
-- TODO: remove this
|
||||
if ui.render then
|
||||
ui.render()
|
||||
else
|
||||
ya.render()
|
||||
end
|
||||
st.dirs[cwd] = nil
|
||||
if not st.repos[repo] then
|
||||
return
|
||||
end
|
||||
|
||||
for _, r in pairs(st.dirs) do
|
||||
if r == repo then
|
||||
return
|
||||
end
|
||||
end
|
||||
st.repos[repo] = nil
|
||||
end)
|
||||
|
||||
---@param st State
|
||||
---@param opts Options
|
||||
local function setup(st, opts)
|
||||
st.dirs = {}
|
||||
st.repos = {}
|
||||
|
||||
opts = opts or {}
|
||||
opts.order = opts.order or 1500
|
||||
|
||||
local t = th.git or {}
|
||||
local styles = {
|
||||
[CODES.ignored] = t.ignored and ui.Style(t.ignored) or ui.Style():fg("darkgray"),
|
||||
[CODES.untracked] = t.untracked and ui.Style(t.untracked) or ui.Style():fg("magenta"),
|
||||
[CODES.modified] = t.modified and ui.Style(t.modified) or ui.Style():fg("yellow"),
|
||||
[CODES.added] = t.added and ui.Style(t.added) or ui.Style():fg("green"),
|
||||
[CODES.deleted] = t.deleted and ui.Style(t.deleted) or ui.Style():fg("red"),
|
||||
[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 "",
|
||||
}
|
||||
|
||||
Linemode:children_add(function(self)
|
||||
local url = self._file.url
|
||||
local repo = st.dirs[tostring(url.base or url.parent)]
|
||||
local code
|
||||
if repo then
|
||||
code = repo == CODES.excluded and CODES.ignored or st.repos[repo][tostring(url):sub(#repo + 2)]
|
||||
end
|
||||
|
||||
if not code or signs[code] == "" then
|
||||
return ""
|
||||
elseif self._file.is_hovered then
|
||||
return ui.Line { " ", signs[code] }
|
||||
else
|
||||
return ui.Line { " ", ui.Span(signs[code]):style(styles[code]) }
|
||||
end
|
||||
end, opts.order)
|
||||
end
|
||||
|
||||
---@type UnstableFetcher
|
||||
local function fetch(_, job)
|
||||
local cwd = job.files[1].url.base or job.files[1].url.parent
|
||||
local repo = root(cwd)
|
||||
if not repo then
|
||||
remove(tostring(cwd))
|
||||
return true
|
||||
end
|
||||
|
||||
local paths = {}
|
||||
for _, file in ipairs(job.files) do
|
||||
paths[#paths + 1] = tostring(file.url)
|
||||
end
|
||||
|
||||
-- stylua: ignore
|
||||
local output, err = Command("git")
|
||||
:cwd(tostring(cwd))
|
||||
:arg({ "--no-optional-locks", "-c", "core.quotePath=", "status", "--porcelain", "-unormal", "--no-renames", "--ignored=matching" })
|
||||
:arg(paths)
|
||||
:stdout(Command.PIPED)
|
||||
:output()
|
||||
if not output then
|
||||
return true, Err("Cannot spawn `git` command, error: %s", err)
|
||||
end
|
||||
|
||||
local changed, excluded = {}, {}
|
||||
for line in output.stdout:gmatch("[^\r\n]+") do
|
||||
local code, path = match(line)
|
||||
if code == CODES.excluded then
|
||||
excluded[#excluded + 1] = path
|
||||
else
|
||||
changed[path] = code
|
||||
end
|
||||
end
|
||||
|
||||
if job.files[1].cha.is_dir then
|
||||
ya.dict_merge(changed, bubble_up(changed))
|
||||
end
|
||||
ya.dict_merge(changed, propagate_down(excluded, cwd, Url(repo)))
|
||||
|
||||
-- Reset the status of any files that don't appear in the output of `git status` to `unknown`,
|
||||
-- so that cleaning up outdated statuses from `st.repos`
|
||||
for _, path in ipairs(paths) do
|
||||
local s = path:sub(#repo + 2)
|
||||
changed[s] = changed[s] or CODES.unknown
|
||||
end
|
||||
|
||||
add(tostring(cwd), repo, changed)
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
return { setup = setup, fetch = fetch }
|
||||
12
yazi/.config/yazi/plugins/git.yazi/types.lua
Normal file
12
yazi/.config/yazi/plugins/git.yazi/types.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
---@class State
|
||||
---@field dirs table<string, string|CODES> Mapping between a directory and its corresponding repository
|
||||
---@field repos table<string, Changes> Mapping between a repository and the status of each of its files
|
||||
|
||||
---@class Options
|
||||
---@field order number The order in which the status is displayed
|
||||
---@field renamed boolean Whether to include renamed files in the status (or treat them as modified)
|
||||
|
||||
-- TODO: move this to `types.yazi` once it's get stable
|
||||
---@alias UnstableFetcher fun(self: unknown, job: { files: File[] }): boolean, Error?
|
||||
|
||||
---@alias Changes table<string, CODES>
|
||||
21
yazi/.config/yazi/plugins/lazygit.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/lazygit.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Darius
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
29
yazi/.config/yazi/plugins/lazygit.yazi/README.md
Normal file
29
yazi/.config/yazi/plugins/lazygit.yazi/README.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# lazygit.yazi
|
||||
Plugin for [Yazi](https://github.com/sxyazi/yazi) to manage git repos with [lazygit](https://github.com/jesseduffield/lazygit)
|
||||
## Dependencies
|
||||
Make sure [lazygit](https://github.com/jesseduffield/lazygit) is installed and in your `PATH`.
|
||||
## Installation
|
||||
|
||||
### Using `ya pack`
|
||||
```
|
||||
ya pack -a Lil-Dank/lazygit
|
||||
```
|
||||
|
||||
### Manual
|
||||
**Linux/macOS**
|
||||
```
|
||||
git clone https://github.com/Lil-Dank/lazygit.yazi.git ~/.config/yazi/plugins/lazygit.yazi
|
||||
```
|
||||
**Windows**
|
||||
```
|
||||
git clone https://github.com/Lil-Dank/lazygit.yazi.git %AppData%\yazi\config\plugins\lazygit.yazi
|
||||
```
|
||||
## Configuration
|
||||
add this to your **keymap.toml** file
|
||||
```toml
|
||||
[[manager.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
|
||||
31
yazi/.config/yazi/plugins/lazygit.yazi/main.lua
Normal file
31
yazi/.config/yazi/plugins/lazygit.yazi/main.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
return {
|
||||
entry = function()
|
||||
local output = Command("git"):arg("status"):stderr(Command.PIPED):output()
|
||||
if output.stderr ~= "" then
|
||||
ya.notify({
|
||||
title = "lazygit",
|
||||
content = "Not in a git directory\nError: " .. output.stderr,
|
||||
level = "warn",
|
||||
timeout = 5,
|
||||
})
|
||||
else
|
||||
permit = ya.hide()
|
||||
local output, err_code = Command("lazygit"):stderr(Command.PIPED):output()
|
||||
if err_code ~= nil then
|
||||
ya.notify({
|
||||
title = "Failed to run lazygit command",
|
||||
content = "Status: " .. err_code,
|
||||
level = "error",
|
||||
timeout = 5,
|
||||
})
|
||||
elseif not output.status.success then
|
||||
ya.notify({
|
||||
title = "lazygit in" .. cwd .. "failed, exit code " .. output.status.code,
|
||||
content = output.stderr,
|
||||
level = "error",
|
||||
timeout = 5,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
21
yazi/.config/yazi/plugins/mount.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/mount.yazi/LICENSE
Normal 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.
|
||||
48
yazi/.config/yazi/plugins/mount.yazi/README.md
Normal file
48
yazi/.config/yazi/plugins/mount.yazi/README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# mount.yazi
|
||||
|
||||
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`
|
||||
|
||||
https://github.com/user-attachments/assets/c6f780ab-458b-420f-85cf-2fc45fcfe3a2
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pkg add yazi-rs/plugins:mount
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `~/.config/yazi/keymap.toml`:
|
||||
|
||||
```toml
|
||||
[[mgr.prepend_keymap]]
|
||||
on = "M"
|
||||
run = "plugin mount"
|
||||
```
|
||||
|
||||
Available keybindings:
|
||||
|
||||
| Key binding | Alternate key | Action |
|
||||
| ------------ | ------------- | --------------------- |
|
||||
| <kbd>q</kbd> | - | Quit the plugin |
|
||||
| <kbd>k</kbd> | <kbd>↑</kbd> | Move up |
|
||||
| <kbd>j</kbd> | <kbd>↓</kbd> | Move down |
|
||||
| <kbd>l</kbd> | <kbd>→</kbd> | Enter the mount point |
|
||||
| <kbd>m</kbd> | - | Mount the partition |
|
||||
| <kbd>u</kbd> | - | Unmount the partition |
|
||||
| <kbd>e</kbd> | - | Eject the disk |
|
||||
|
||||
## TODO
|
||||
|
||||
- Custom keybindings
|
||||
- Windows support (I don't have an Windows machine for testing, PRs welcome!)
|
||||
- Support mount, unmount, and eject the entire disk
|
||||
|
||||
## License
|
||||
|
||||
This plugin is MIT-licensed. For more information check the [LICENSE](LICENSE) file.
|
||||
285
yazi/.config/yazi/plugins/mount.yazi/main.lua
Normal file
285
yazi/.config/yazi/plugins/mount.yazi/main.lua
Normal file
@@ -0,0 +1,285 @@
|
||||
--- @since 25.5.31
|
||||
|
||||
local toggle_ui = ya.sync(function(self)
|
||||
if self.children then
|
||||
Modal:children_remove(self.children)
|
||||
self.children = nil
|
||||
else
|
||||
self.children = Modal:children_add(self, 10)
|
||||
end
|
||||
ya.render()
|
||||
end)
|
||||
|
||||
local subscribe = ya.sync(function(self)
|
||||
ps.unsub("mount")
|
||||
ps.sub("mount", function() ya.emit("plugin", { self._id, "refresh" }) end)
|
||||
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()
|
||||
end)
|
||||
|
||||
local active_partition = ya.sync(function(self) return self.partitions[self.cursor + 1] end)
|
||||
|
||||
local update_cursor = ya.sync(function(self, cursor)
|
||||
if #self.partitions == 0 then
|
||||
self.cursor = 0
|
||||
else
|
||||
self.cursor = ya.clamp(0, self.cursor + cursor, #self.partitions - 1)
|
||||
end
|
||||
ya.render()
|
||||
end)
|
||||
|
||||
local M = {
|
||||
keys = {
|
||||
{ on = "q", run = "quit" },
|
||||
|
||||
{ on = "k", run = "up" },
|
||||
{ on = "j", run = "down" },
|
||||
{ on = "l", run = { "enter", "quit" } },
|
||||
|
||||
{ on = "<Up>", run = "up" },
|
||||
{ on = "<Down>", run = "down" },
|
||||
{ on = "<Right>", run = { "enter", "quit" } },
|
||||
|
||||
{ on = "m", run = "mount" },
|
||||
{ on = "u", run = "unmount" },
|
||||
{ on = "e", run = "eject" },
|
||||
},
|
||||
}
|
||||
|
||||
function M:new(area)
|
||||
self:layout(area)
|
||||
return self
|
||||
end
|
||||
|
||||
function M:layout(area)
|
||||
local chunks = ui.Layout()
|
||||
:constraints({
|
||||
ui.Constraint.Percentage(10),
|
||||
ui.Constraint.Percentage(80),
|
||||
ui.Constraint.Percentage(10),
|
||||
})
|
||||
:split(area)
|
||||
|
||||
local chunks = ui.Layout()
|
||||
:direction(ui.Layout.HORIZONTAL)
|
||||
:constraints({
|
||||
ui.Constraint.Percentage(10),
|
||||
ui.Constraint.Percentage(80),
|
||||
ui.Constraint.Percentage(10),
|
||||
})
|
||||
:split(chunks[2])
|
||||
|
||||
self._area = chunks[2]
|
||||
end
|
||||
|
||||
function M:entry(job)
|
||||
if job.args[1] == "refresh" then
|
||||
return update_partitions(self.obtain())
|
||||
end
|
||||
|
||||
toggle_ui()
|
||||
update_partitions(self.obtain())
|
||||
subscribe()
|
||||
|
||||
local tx1, rx1 = ya.chan("mpsc")
|
||||
local tx2, rx2 = ya.chan("mpsc")
|
||||
function producer()
|
||||
while true do
|
||||
local cand = self.keys[ya.which { cands = self.keys, silent = true }] or { run = {} }
|
||||
for _, r in ipairs(type(cand.run) == "table" and cand.run or { cand.run }) do
|
||||
tx1:send(r)
|
||||
if r == "quit" then
|
||||
toggle_ui()
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function consumer1()
|
||||
repeat
|
||||
local run = rx1:recv()
|
||||
if run == "quit" then
|
||||
tx2:send(run)
|
||||
break
|
||||
elseif run == "up" then
|
||||
update_cursor(-1)
|
||||
elseif run == "down" then
|
||||
update_cursor(1)
|
||||
elseif run == "enter" then
|
||||
local active = active_partition()
|
||||
if active and active.dist then
|
||||
ya.emit("cd", { active.dist })
|
||||
end
|
||||
else
|
||||
tx2:send(run)
|
||||
end
|
||||
until not run
|
||||
end
|
||||
|
||||
function consumer2()
|
||||
repeat
|
||||
local run = rx2:recv()
|
||||
if run == "quit" then
|
||||
break
|
||||
elseif run == "mount" then
|
||||
self.operate("mount")
|
||||
elseif run == "unmount" then
|
||||
self.operate("unmount")
|
||||
elseif run == "eject" then
|
||||
self.operate("eject")
|
||||
end
|
||||
until not run
|
||||
end
|
||||
|
||||
ya.join(producer, consumer1, consumer2)
|
||||
end
|
||||
|
||||
function M:reflow() return { self } end
|
||||
|
||||
function M:redraw()
|
||||
local rows = {}
|
||||
for _, p in ipairs(self.partitions or {}) do
|
||||
if not p.sub then
|
||||
rows[#rows + 1] = ui.Row { p.main }
|
||||
elseif p.sub == "" then
|
||||
rows[#rows + 1] = ui.Row { p.main, p.label or "", p.dist or "", p.fstype or "" }
|
||||
else
|
||||
rows[#rows + 1] = ui.Row { " " .. p.sub, p.label or "", p.dist or "", p.fstype or "" }
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
ui.Clear(self._area),
|
||||
ui.Border(ui.Edge.ALL)
|
||||
:area(self._area)
|
||||
:type(ui.Border.ROUNDED)
|
||||
:style(ui.Style():fg("blue"))
|
||||
:title(ui.Line("Mount"):align(ui.Align.CENTER)),
|
||||
ui.Table(rows)
|
||||
:area(self._area:pad(ui.Pad(1, 2, 1, 2)))
|
||||
:header(ui.Row({ "Src", "Label", "Dist", "FSType" }):style(ui.Style():bold()))
|
||||
:row(self.cursor)
|
||||
:row_style(ui.Style():fg("blue"):underline())
|
||||
:widths {
|
||||
ui.Constraint.Length(20),
|
||||
ui.Constraint.Length(20),
|
||||
ui.Constraint.Percentage(70),
|
||||
ui.Constraint.Length(10),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
function M.obtain()
|
||||
local tbl = {}
|
||||
local last
|
||||
for _, p in ipairs(fs.partitions()) do
|
||||
local main, sub = M.split(p.src)
|
||||
if main and last ~= main then
|
||||
if p.src == main then
|
||||
last, p.main, p.sub, tbl[#tbl + 1] = p.src, p.src, "", p
|
||||
else
|
||||
last, tbl[#tbl + 1] = main, { src = main, main = main, sub = "" }
|
||||
end
|
||||
end
|
||||
if sub then
|
||||
if tbl[#tbl].sub == "" and tbl[#tbl].main == main then
|
||||
tbl[#tbl].sub = nil
|
||||
end
|
||||
p.main, p.sub, tbl[#tbl + 1] = main, sub, p
|
||||
end
|
||||
end
|
||||
table.sort(M.fillin(tbl), function(a, b)
|
||||
if a.main == b.main then
|
||||
return (a.sub or "") < (b.sub or "")
|
||||
else
|
||||
return a.main > b.main
|
||||
end
|
||||
end)
|
||||
return tbl
|
||||
end
|
||||
|
||||
function M.split(src)
|
||||
local pats = {
|
||||
{ "^/dev/sd[a-z]", "%d+$" }, -- /dev/sda1
|
||||
{ "^/dev/nvme%d+n%d+", "p%d+$" }, -- /dev/nvme0n1p1
|
||||
{ "^/dev/mmcblk%d+", "p%d+$" }, -- /dev/mmcblk0p1
|
||||
{ "^/dev/disk%d+", ".+$" }, -- /dev/disk1s1
|
||||
}
|
||||
for _, p in ipairs(pats) do
|
||||
local main = src:match(p[1])
|
||||
if main then
|
||||
return main, src:sub(#main + 1):match(p[2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.fillin(tbl)
|
||||
if ya.target_os() ~= "linux" then
|
||||
return tbl
|
||||
end
|
||||
|
||||
local sources, indices = {}, {}
|
||||
for i, p in ipairs(tbl) do
|
||||
if p.sub and not p.fstype then
|
||||
sources[#sources + 1], indices[p.src] = p.src, i
|
||||
end
|
||||
end
|
||||
if #sources == 0 then
|
||||
return tbl
|
||||
end
|
||||
|
||||
local output, err = Command("lsblk"):arg({ "-p", "-o", "name,fstype", "-J" }):arg(sources):output()
|
||||
if err then
|
||||
ya.dbg("Failed to fetch filesystem types for unmounted partitions: " .. err)
|
||||
return tbl
|
||||
end
|
||||
|
||||
local t = ya.json_decode(output and output.stdout or "")
|
||||
for _, p in ipairs(t and t.blockdevices or {}) do
|
||||
tbl[indices[p.name]].fstype = p.fstype
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
function M.operate(type)
|
||||
local active = active_partition()
|
||||
if not active then
|
||||
return
|
||||
elseif not active.sub then
|
||||
return -- TODO: mount/unmount main disk
|
||||
end
|
||||
|
||||
local output, err
|
||||
if ya.target_os() == "macos" then
|
||||
output, err = Command("diskutil"):arg({ type, active.src }):output()
|
||||
end
|
||||
if ya.target_os() == "linux" then
|
||||
if type == "eject" then
|
||||
Command("udisksctl"):arg({ "unmount", "-b", active.src }):status()
|
||||
output, err = Command("udisksctl"):arg({ "power-off", "-b", active.src }):output()
|
||||
else
|
||||
output, err = Command("udisksctl"):arg({ type, "-b", active.src }):output()
|
||||
end
|
||||
end
|
||||
|
||||
if not output then
|
||||
M.fail("Failed to %s `%s`: %s", type, active.src, err)
|
||||
elseif not output.status.success then
|
||||
M.fail("Failed to %s `%s`: %s", type, active.src, output.stderr)
|
||||
end
|
||||
end
|
||||
|
||||
function M.fail(...) ya.notify { title = "Mount", content = string.format(...), timeout = 10, level = "error" } end
|
||||
|
||||
function M:click() end
|
||||
|
||||
function M:scroll() end
|
||||
|
||||
function M:touch() end
|
||||
|
||||
return M
|
||||
21
yazi/.config/yazi/plugins/nbpreview.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/nbpreview.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
79
yazi/.config/yazi/plugins/nbpreview.yazi/README.md
Normal file
79
yazi/.config/yazi/plugins/nbpreview.yazi/README.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# 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/).
|
||||
58
yazi/.config/yazi/plugins/nbpreview.yazi/main.lua
Normal file
58
yazi/.config/yazi/plugins/nbpreview.yazi/main.lua
Normal file
@@ -0,0 +1,58 @@
|
||||
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
|
||||
21
yazi/.config/yazi/plugins/rich-preview.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/rich-preview.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
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.
|
||||
75
yazi/.config/yazi/plugins/rich-preview.yazi/README.md
Normal file
75
yazi/.config/yazi/plugins/rich-preview.yazi/README.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# rich-preview.yazi
|
||||
|
||||
Preview file types using `rich` command in Yazi. This plugin allows preview for various filetypes including -
|
||||
|
||||
- Markdown
|
||||
- Jupyter notebook
|
||||
- JSON
|
||||
- CSV
|
||||
- RestructuredText
|
||||
|
||||
## Previews/Screenshots
|
||||
|
||||
[rich-preview1.webm](https://github.com/user-attachments/assets/580e36a8-249f-48a8-95fc-8c3d60e6a7d7)
|
||||
|
||||
## Requirements
|
||||
|
||||
- [Yazi](https://github.com/sxyazi/yazi) v0.4 or higher.
|
||||
- [rich-cli](https://github.com/Textualize/rich) v13.7.1 or higher.
|
||||
|
||||
## Installation
|
||||
|
||||
To install this plugin, simply run-
|
||||
|
||||
```bash
|
||||
ya pack -a AnirudhG07/rich-preview
|
||||
## For linux and MacOS
|
||||
git clone https://github.com/AnirudhG07/rich-preview.yazi.git ~/.config/yazi/plugins/rich-preview.yazi
|
||||
|
||||
## For Windows
|
||||
git clone https://github.com/AnirudhG07/rich-preview.yazi.git %AppData%\yazi\config\plugins\rich-preview.yazi
|
||||
```
|
||||
|
||||
## Usages
|
||||
|
||||
The `rich` commands automatically detects if the file is markdown, csv, json, etc. files and accordingly the preview is viewed.
|
||||
|
||||
Add the below to your `yazi.toml` file to allow the respective file to previewed using `rich`.
|
||||
|
||||
```toml
|
||||
[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.
|
||||
]
|
||||
```
|
||||
|
||||
## Configurations
|
||||
|
||||
If you would like to use `rich` with more configurations, you can go to `init.lua` and edit the arguments in the code with your preferences. You can view the options using `rich --help`.
|
||||
|
||||
```lua
|
||||
-- init.lua
|
||||
"-j",
|
||||
"--left",
|
||||
"--line-numbers",
|
||||
"--force-terminal",
|
||||
"--panel=rounded",
|
||||
"--guides",
|
||||
"--max-width" -- to area of preview
|
||||
```
|
||||
|
||||
You can add more, remove and choose themes as you wish. You can set styles or Themes(as mentioned in `rich --help`) by `--theme=your_theme` and similarly for style.
|
||||
|
||||
## Notes
|
||||
|
||||
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.
|
||||
|
||||
# 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/).
|
||||
53
yazi/.config/yazi/plugins/rich-preview.yazi/main.lua
Normal file
53
yazi/.config/yazi/plugins/rich-preview.yazi/main.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local M = {}
|
||||
|
||||
function M:peek(job)
|
||||
local child = Command("rich")
|
||||
:arg({
|
||||
"-j",
|
||||
"--left",
|
||||
"--line-numbers",
|
||||
"--force-terminal",
|
||||
"--panel=rounded",
|
||||
"--guides",
|
||||
"--max-width",
|
||||
tostring(job.area.w),
|
||||
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
|
||||
21
yazi/.config/yazi/plugins/time-travel.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/time-travel.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Xianyi Lin
|
||||
|
||||
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.
|
||||
35
yazi/.config/yazi/plugins/time-travel.yazi/README.md
Normal file
35
yazi/.config/yazi/plugins/time-travel.yazi/README.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# 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.
|
||||
386
yazi/.config/yazi/plugins/time-travel.yazi/main.lua
Normal file
386
yazi/.config/yazi/plugins/time-travel.yazi/main.lua
Normal file
@@ -0,0 +1,386 @@
|
||||
---@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,
|
||||
}
|
||||
21
yazi/.config/yazi/plugins/toggle-view.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/toggle-view.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 dawsers
|
||||
|
||||
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.
|
||||
32
yazi/.config/yazi/plugins/toggle-view.yazi/README.md
Normal file
32
yazi/.config/yazi/plugins/toggle-view.yazi/README.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# 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.
|
||||
|
||||
63
yazi/.config/yazi/plugins/toggle-view.yazi/main.lua
Normal file
63
yazi/.config/yazi/plugins/toggle-view.yazi/main.lua
Normal file
@@ -0,0 +1,63 @@
|
||||
--- @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 }
|
||||
21
yazi/.config/yazi/plugins/yamb.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/yamb.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Hunter Hwang
|
||||
|
||||
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.
|
||||
112
yazi/.config/yazi/plugins/yamb.yazi/README.md
Normal file
112
yazi/.config/yazi/plugins/yamb.yazi/README.md
Normal file
@@ -0,0 +1,112 @@
|
||||
# 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"
|
||||
```
|
||||
355
yazi/.config/yazi/plugins/yamb.yazi/main.lua
Normal file
355
yazi/.config/yazi/plugins/yamb.yazi/main.lua
Normal file
@@ -0,0 +1,355 @@
|
||||
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,
|
||||
}
|
||||
21
yazi/.config/yazi/plugins/yaziline.yazi/LICENSE
Normal file
21
yazi/.config/yazi/plugins/yaziline.yazi/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 llanosrocas
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
154
yazi/.config/yazi/plugins/yaziline.yazi/README.md
Normal file
154
yazi/.config/yazi/plugins/yaziline.yazi/README.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# yaziline.yazi
|
||||
|
||||
Simple lualine-like status line for yazi.
|
||||
|
||||
Read more about features and configuration [here](#features).
|
||||
|
||||
> ⚠️ **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.
|
||||
|
||||

|
||||
|
||||
## Requirements
|
||||
|
||||
- yazi version >= [25.4.8](https://github.com/sxyazi/yazi/releases/tag/v25.4.8)
|
||||
- Font with symbol support. For example [Nerd Fonts](https://www.nerdfonts.com/).
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pack -a llanosrocas/yaziline
|
||||
```
|
||||
|
||||
Or manually copy `init.lua` to the `~/.config/yazi/plugins/yaziline.yazi/init.lua`
|
||||
|
||||
## Usage
|
||||
|
||||
Add this to your `~/.config/yazi/init.lua`:
|
||||
|
||||
```lua
|
||||
require("yaziline"):setup()
|
||||
```
|
||||
|
||||
Optionally, configure line:
|
||||
|
||||
```lua
|
||||
require("yaziline"):setup({
|
||||
color = "#98c379", -- main theme color
|
||||
default_files_color = "darkgray", -- color of the file counter when it's inactive
|
||||
selected_files_color = "white",
|
||||
yanked_files_color = "green",
|
||||
cut_files_color = "red",
|
||||
|
||||
separator_style = "angly", -- "angly" | "curvy" | "liney" | "empty"
|
||||
separator_open = "",
|
||||
separator_close = "",
|
||||
separator_open_thin = "",
|
||||
separator_close_thin = "",
|
||||
separator_head = "",
|
||||
separator_tail = "",
|
||||
|
||||
select_symbol = "",
|
||||
yank_symbol = "",
|
||||
|
||||
filename_max_length = 24, -- truncate when filename > 24
|
||||
filename_truncate_length = 6, -- leave 6 chars on both sides
|
||||
filename_truncate_separator = "..." -- the separator of the truncated filename
|
||||
})
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
### Preconfigured separators
|
||||
|
||||
Choose your style:
|
||||
|
||||
- `angly`
|
||||

|
||||
- `curvy`
|
||||

|
||||
- `liney`
|
||||

|
||||
- `empty`
|
||||

|
||||
|
||||
### 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
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
_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
|
||||
})
|
||||
```
|
||||
|
||||

|
||||
|
||||
_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:
|
||||
|
||||

|
||||
|
||||
### Selected and Yanked Counter
|
||||
|
||||
Displays the number of selected ('S') and yanked ('Y') files on the left. If files are cut, the yank counter changes color, since its `yank --cut` under the hood.
|
||||
|
||||
### Truncated filename
|
||||
|
||||
Displays the truncated filename on the left, which is useful for smaller windows or long filenames. By default, it's 24 characters with trimming to 12 (6 + 6). Adjust in the `setup`.
|
||||
|
||||
```lua
|
||||
require("yaziline"):setup({
|
||||
filename_max_length = 24, -- truncate when filename > 24
|
||||
filename_truncate_length = 6, -- leave 6 chars on both sides
|
||||
filename_truncate_separator = "..." -- the separator of the truncated filename
|
||||
})
|
||||
```
|
||||
|
||||
### ISO Date for 'Modified'
|
||||
|
||||
On the right, you'll find the date and time the file was modified, formatted in an [ISO](https://en.wikipedia.org/wiki/ISO_8601)-like string for universal date representation. Adjust in the `Status:date` function.
|
||||
|
||||
## Credits
|
||||
|
||||
- [yazi source code](https://github.com/sxyazi/yazi)
|
||||
- [yatline.yazi](https://github.com/imsi32/yatline.yazi/tree/main)
|
||||
- [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim)
|
||||
199
yazi/.config/yazi/plugins/yaziline.yazi/main.lua
Normal file
199
yazi/.config/yazi/plugins/yaziline.yazi/main.lua
Normal file
@@ -0,0 +1,199 @@
|
||||
local function setup(_, options)
|
||||
options = options or {}
|
||||
|
||||
local default_separators = {
|
||||
angly = { "", "", "", "" },
|
||||
curvy = { "", "", "", "" },
|
||||
liney = { "", "", "|", "|" },
|
||||
empty = { "", "", "", "" },
|
||||
}
|
||||
local separators = default_separators[options.separator_style or "angly"]
|
||||
|
||||
local config = {
|
||||
separator_styles = {
|
||||
separator_open = options.separator_open or separators[1],
|
||||
separator_close = options.separator_close or separators[2],
|
||||
separator_open_thin = options.separator_open_thin or separators[3],
|
||||
separator_close_thin = options.separator_close_thin or separators[4],
|
||||
separator_head = options.separator_head or "",
|
||||
separator_tail = options.separator_tail or "",
|
||||
},
|
||||
select_symbol = options.select_symbol or "S",
|
||||
yank_symbol = options.yank_symbol or "Y",
|
||||
|
||||
filename_max_length = options.filename_max_length or 24,
|
||||
filename_truncate_length = options.filename_truncate_length or 6,
|
||||
filename_truncate_separator = options.filename_truncate_separator or "...",
|
||||
|
||||
color = options.color or nil,
|
||||
default_files_color = options.default_files_color
|
||||
or th.which.separator_style.fg
|
||||
or "darkgray",
|
||||
selected_files_color = options.selected_files_color
|
||||
or th.mgr.count_selected.bg
|
||||
or "white",
|
||||
yanked_files_color = options.selected_files_color
|
||||
or th.mgr.count_copied.bg
|
||||
or "green",
|
||||
cut_files_color = options.cut_files_color
|
||||
or th.mgr.count_cut.bg
|
||||
or "red",
|
||||
}
|
||||
|
||||
local current_separator_style = config.separator_styles
|
||||
|
||||
function Header:count()
|
||||
return ui.Line({})
|
||||
end
|
||||
|
||||
function Status:mode()
|
||||
local mode = tostring(self._tab.mode):upper()
|
||||
|
||||
local style = self:style()
|
||||
return ui.Line({
|
||||
ui.Span(current_separator_style.separator_head)
|
||||
:fg(config.color or style.main.bg),
|
||||
ui.Span(" " .. mode .. " ")
|
||||
:fg(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()
|
||||
local h = self._current.hovered
|
||||
if not h then
|
||||
return ""
|
||||
end
|
||||
|
||||
local truncated_name = self:truncate_name(h.name, config.filename_max_length)
|
||||
|
||||
local style = self:style()
|
||||
return ui.Line {
|
||||
ui.Span(current_separator_style.separator_close .. " ")
|
||||
:fg(th.which.separator_style.fg),
|
||||
ui.Span(truncated_name)
|
||||
:fg(config.color or style.main.bg),
|
||||
}
|
||||
end
|
||||
|
||||
function Status:files()
|
||||
local files_yanked = #cx.yanked
|
||||
local files_selected = #cx.active.selected
|
||||
local files_cut = cx.yanked.is_cut
|
||||
|
||||
local selected_fg = files_selected > 0
|
||||
and config.selected_files_color
|
||||
or config.default_files_color
|
||||
local yanked_fg = files_yanked > 0
|
||||
and
|
||||
(files_cut
|
||||
and config.cut_files_color
|
||||
or config.yanked_files_color
|
||||
)
|
||||
or config.default_files_color
|
||||
|
||||
local yanked_text = files_yanked > 0
|
||||
and config.yank_symbol .. " " .. files_yanked
|
||||
or config.yank_symbol .. " 0"
|
||||
|
||||
return ui.Line({
|
||||
ui.Span(" " .. current_separator_style.separator_close_thin .. " ")
|
||||
:fg(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
|
||||
|
||||
return ui.Span(os.date("%Y-%m-%d %H:%M", time) .. " " .. current_separator_style.separator_open_thin .. " ")
|
||||
:fg(th.which.separator_style.fg)
|
||||
end
|
||||
|
||||
function Status:percent()
|
||||
local percent = 0
|
||||
local cursor = self._tab.current.cursor
|
||||
local length = #self._tab.current.files
|
||||
if cursor ~= 0 and length ~= 0 then
|
||||
percent = math.floor((cursor + 1) * 100 / length)
|
||||
end
|
||||
|
||||
if percent == 0 then
|
||||
percent = " Top "
|
||||
elseif percent == 100 then
|
||||
percent = " Bot "
|
||||
else
|
||||
percent = string.format(" %2d%% ", percent)
|
||||
end
|
||||
|
||||
local style = self:style()
|
||||
return ui.Line({
|
||||
ui.Span(" " .. current_separator_style.separator_open)
|
||||
:fg(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: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 }
|
||||
4
yazi/.config/yazi/theme.toml
Normal file
4
yazi/.config/yazi/theme.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[flavor]
|
||||
dark = "catppuccin-mocha"
|
||||
light = "catppuccin-mocha"
|
||||
|
||||
250
yazi/.config/yazi/yazi.toml
Normal file
250
yazi/.config/yazi/yazi.toml
Normal file
@@ -0,0 +1,250 @@
|
||||
## 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"
|
||||
sort_sensitive = 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 ]
|
||||
|
||||
[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" },
|
||||
]
|
||||
open = [
|
||||
{ run = 'xdg-open "$1"', desc = "Open", for = "linux" },
|
||||
{ run = 'open "$@"', desc = "Open", for = "macos" },
|
||||
{ run = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" },
|
||||
]
|
||||
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" },
|
||||
]
|
||||
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" ] },
|
||||
]
|
||||
|
||||
[tasks]
|
||||
micro_workers = 10
|
||||
macro_workers = 10
|
||||
bizarre_retry = 3
|
||||
image_alloc = 536870912 # 512MB
|
||||
image_bound = [ 0, 0 ]
|
||||
suppress_preload = true
|
||||
|
||||
[plugin]
|
||||
|
||||
#fetchers = [
|
||||
# # Mimetype
|
||||
# { id = "mime", name = "*", run = "mime", if = "!mime", prio = "high" },
|
||||
# ]
|
||||
prepend_fetchers = [
|
||||
{ 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" },
|
||||
]
|
||||
preloaders = [
|
||||
# Image
|
||||
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
||||
{ mime = "image/*", run = "image" },
|
||||
# Video
|
||||
#{ mime = "video/*", run = "video" },
|
||||
# PDF
|
||||
{ mime = "application/pdf", run = "pdf" },
|
||||
# Font
|
||||
{ mime = "font/*", run = "font" },
|
||||
{ mime = "application/ms-opentype", run = "font" },
|
||||
]
|
||||
previewers = [
|
||||
{ name = "*/", run = "folder", sync = true },
|
||||
# Code
|
||||
{ mime = "text/*", run = "code" },
|
||||
{ mime = "*/{xml,javascript,wine-extension-ini}", run = "code" },
|
||||
# JSON
|
||||
{ mime = "application/{json,ndjson}", run = "json" },
|
||||
# Image
|
||||
{ mime = "image/{avif,hei?,jxl,svg+xml}", run = "magick" },
|
||||
{ mime = "image/*", run = "image" },
|
||||
# # Video
|
||||
#{ 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.
|
||||
]
|
||||
|
||||
[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
|
||||
Reference in New Issue
Block a user