-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Enhancing --memory_unit functionality #2225
base: master
Are you sure you want to change the base?
Conversation
Improving dylanaraps@0435dcd - Implementing dylanaraps#1170 (comment) to avoid awk usage. - Adding ability to configure precision of output using `mem_precision` which defaults to `2`. - Added `tib` to accommodate TiB mentioned in dylanaraps#1170 (comment)
added `tib` to description of `memory_unit`.
…functionality Upstream PR: dylanaraps/neofetch#2225 Thanks to @TriMoon Co-authored-by: ©TriMoon™ <TriMoon@users.noreply.github.com>
…functionality Upstream PR: dylanaraps/neofetch#2225 Thanks to @TriMoon Co-authored-by: ©TriMoon™ <TriMoon@users.noreply.github.com>
Added `tib` to usage output of `-memory_unit`.
I'm editing online, will check/address those warnings later 😉 |
I just fixed it for you: case $memory_unit in
tib)
mem_label=TiB
memory_unit_divider=$((1024 * 1024))
;;
gib)
mem_label=GiB
memory_unit_divider=1024
;;
kib)
mem_used=$((mem_used * 1024))
mem_total=$((mem_total * 1024))
mem_label=KiB
;;
esac
case $memory_unit in
tib|gib)
printf -v mem_used "%'.*f" \
"${mem_precision:-2}" \
"$((mem_used / memory_unit_divider)).$((mem_used % memory_unit_divider))"
printf -v mem_total "%'.*f" \
"${mem_precision:-2}" \
"$((mem_total / memory_unit_divider)).$((mem_total % memory_unit_divider))"
;;
esac But I can't push to your branch though |
Hahaha that's a way to do it also ofcourse, by creating an extra block.... I know i should have started with a "Draft" pull request but ahh well heheheh |
Added `--memory_precision` flag, default=`2`.
Fixing shellcheck warnings mentioned in dylanaraps#2225 (comment)
Separating calculations as shown in dylanaraps#2225 (comment)
Making calculations general purpose.
@hykilpikonna, i just noticed the current non-patched version does wrong arithmetic in it's attempt to convert Lines 2538 to 2649 in 0435dcd
It does integer calculation instead of floating point... I already know i will use the same kind of So I'm going to first correct that before going further, as it will change more stuff. |
That won't be needed when we keep the original values in |
Invited as collaborator 😉 |
Thanks! I just pushed my commit fixing the memory progress bar issue
Yea, I think creating a function for floating-point calculations would be nice, and we can keep the raw value in bytes or kib to reduce the number of calculations and conversions. Let me know when it's ready to merge! |
These changes, with your fix could be merged first, because the floating point calculation functionality would be something completely different and extra to this MR 😉 |
…functionality Upstream PR: dylanaraps/neofetch#2225 Thanks to @TriMoon Co-authored-by: ©TriMoon™ <TriMoon@users.noreply.github.com>
Okay, just merged into hyfetch!
|
Description
Improving 0435dcd
Features
mem_precision
which defaults to2
.tib
to accommodate TiB mentioned in Option to show memory in GB #1170 (comment)