From c02d69590bda49babe0883ff78341d92e557f381 Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 26 Jan 2024 16:35:36 +0800 Subject: [PATCH] feat: shorten unit names and add more units to `ya.readable_size` --- yazi-plugin/preset/ya.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/yazi-plugin/preset/ya.lua b/yazi-plugin/preset/ya.lua index 0c2158a6..d21e89f1 100644 --- a/yazi-plugin/preset/ya.lua +++ b/yazi-plugin/preset/ya.lua @@ -45,13 +45,13 @@ end function ya.basename(str) return string.gsub(str, "(.*[/\\])(.*)", "%2") end function ya.readable_size(size) - local units = { "B", "KB", "MB", "GB", "TB", "PB", "EB" } + local units = { "B", "K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q" } local i = 1 while size > 1024.0 and i < #units do size = size / 1024.0 i = i + 1 end - return string.format("%.1f %s", size, units[i]) + return string.format("%.1f%s", size, units[i]) end function ya.readable_path(path)