Lsd: FR: show fraction in file sizes only for values less than 100

Created on 4 Sep 2020  ·  5Comments  ·  Source: Peltoche/lsd

From a certain size on the fraction is not that important anymore when viewed in default mode (which is the equivalent to ls' human-readable).

So maybe values less than 100 should be displayed with a fraction, equal/larger values as integer.

But those sizes should be displayed always as a number with fraction:

.rw-r--r-- me user 2020-04-04 12:36:29 5.9 MB  IMG_20200308_162055.jpg
.rw-r--r-- me user 2020-04-04 12:36:33   6 MB  IMG_20200308_162058.jpg

-> better to see 6.0 MB instead of integer value.

Most helpful comment

I would be happy to implement this if nobody else has picked it up yet.

All 5 comments

I would be happy to implement this if nobody else has picked it up yet.

Nobody has picked it up yet. Feel free to take it up :)

My bad, I just realized that this would deviate from how ls does it and we would like to keep the behaviour somewhat consistent to ls.

ls (GNU coreutils) 8.30 (Linux Mint, inhouse linux)

$ \ls -hl
drwxrwxr-x 2 user_b user_b 4.0K Jul 23 11:19  ISO
-rw-rw-r-- 1 user_b user_b 2.9K Sep  8 14:36  GCF_009858895.2_ASM985889v3_genomic.gff.gz
-rw-rw-r-- 1 user_b user_b 225K Aug 19 11:59  2020.07.20.211573.source.xml
-rwxr-xr-x 1 user_b user_b 499M Jul 21 21:18  Designer3_linux64_installer.run
-rw-rw-r-- 1 user_b user_b  37K Sep  3 08:50  GSAF-Illumina-allflavors-030920-0150-2822.pdf

lsd 0.18.0 (Linux Mint, cargo install)

$ lsd --long --blocks permission,user,group,date,size,name --date +"%Y-%m-%d %H:%M:%S"
drwxrwxr-x user_b user_b 2020-07-23 11:19:35     4 KB  ISO
.rw-rw-r-- user_b user_b 2020-09-08 14:36:07   2.8 KB  GCF_009858895.2_ASM985889v3_genomic.gff.gz
.rw-rw-r-- user_b user_b 2020-08-19 11:59:30 224.9 KB  2020.07.20.211573.source.xml
.rwxr-xr-x user_b user_b 2020-07-21 21:18:04   498 MB  Designer3_linux64_installer.run
.rw-rw-r-- user_b user_b 2020-09-03 08:50:35  36.1 KB  GSAF-Illumina-allflavors-030920-0150-2822.pdf
  • GNU ls: 4.0 is diplayed as 4.0. Not as integer.
  • GNU ls: values between 10 and 1000 are displayed as integer. Not as fraction.

Still I think that values should be displayed as the same type, 4.1=4.1 and 4=4.0.
Also I think that fractions are just important for smaller values, here/now below 10.

But just my 2p :-)

confirm in ubuntu and macOS, thanks for the detail!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alichtman picture alichtman  ·  3Comments

augustobmoura picture augustobmoura  ·  5Comments

spencerwooo picture spencerwooo  ·  3Comments

Koovu picture Koovu  ·  7Comments

jcassee picture jcassee  ·  5Comments