mirror of
https://github.com/kristoferssolo/solorice.git
synced 2026-02-04 06:32:03 +00:00
Update 2025-07-16
This commit is contained in:
@@ -26,6 +26,13 @@ what-size supports Yazi on Linux, macOS, and Windows.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
ya pkg add pirafrank/what-size
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
**DEPRECATED**
|
||||
```sh
|
||||
ya pack -a 'pirafrank/what-size'
|
||||
```
|
||||
@@ -35,26 +42,26 @@ ya pack -a 'pirafrank/what-size'
|
||||
Add this to your `~/.config/yazi/keymap.toml`:
|
||||
|
||||
```toml
|
||||
[manager]
|
||||
prepend_keymap = [
|
||||
{ on = [ ".", "s" ], run = "plugin what-size", desc = "Calc size of selection or cwd" },
|
||||
]
|
||||
[[mgr.prepend_keymap]]
|
||||
on = [ ".", "s" ]
|
||||
run = "plugin what-size"
|
||||
desc = "Calc size of selection or cwd"
|
||||
```
|
||||
|
||||
If you want to copy the result to clipboard, you can add `--clipboard` or `-c` as 2nd positional argument:
|
||||
|
||||
```toml
|
||||
[manager]
|
||||
prepend_keymap = [
|
||||
{ on = [ ".", "s" ], run = "plugin what-size -- '--clipboard'", desc = "Calc size of selection or cwd" },
|
||||
]
|
||||
[[mgr.prepend_keymap]]
|
||||
on = [ ".", "s" ]
|
||||
run = "plugin what-size -- '--clipboard'"
|
||||
desc = "Calc size of selection or cwd"
|
||||
```
|
||||
|
||||
```toml
|
||||
[manager]
|
||||
prepend_keymap = [
|
||||
{ on = [ ".", "s" ], run = "plugin what-size -- '-c'", desc = "Calc size of selection or cwd" },
|
||||
]
|
||||
[[mgr.prepend_keymap]]
|
||||
on = [ ".", "s" ]
|
||||
run = "plugin what-size -- '-c'"
|
||||
desc = "Calc size of selection or cwd"
|
||||
```
|
||||
|
||||
Change to whatever keybinding you like.
|
||||
|
||||
@@ -46,7 +46,13 @@ local function get_total_size(items)
|
||||
return total
|
||||
else
|
||||
local arg = ya.target_os() == "macos" and "-scA" or "-scb"
|
||||
local output, err = Command("du"):arg(arg):arg(items):output()
|
||||
-- pass args as string
|
||||
local cmd = Command("du"):arg(arg)
|
||||
for _, path in ipairs(items) do
|
||||
cmd = cmd:arg(path)
|
||||
end
|
||||
local output, err = cmd:output()
|
||||
|
||||
if not output then
|
||||
ya.err("Failed to run du: " .. err)
|
||||
end
|
||||
@@ -93,4 +99,4 @@ return {
|
||||
timeout = 4,
|
||||
}
|
||||
end,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user