Lsd: show hard link number with -l (second column of ls -l)

Created on 30 Aug 2020  ยท  17Comments  ยท  Source: Peltoche/lsd

excuse me. I know this is not the right section, but I would like to know how to show hard links too. In help I can't find anything and there is no manual. Thanks and sorry again

good first issue kinfeature

Most helpful comment

Well that works for files in the same directory:

$ lsd -li s*
1803502 .rwxr-xr-x user_b user_b 2.7 KB Wed Sep 30 21:22:58 2020 ๏’‰ run.hg38.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏’‰ run.mm10.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏€– run.mm10.sh.link

When files are not in the same directory, it gets complicated :-)

What @M4tT3d is referring to is to get column number two of ls -l:

-rwxr-xr-x 1 user_b user_b 2804 30. Sep 21:22 run.hg38.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh.link

All 17 comments

I am not sure if there is a standard way to do this, but you can check the inode number of files by using lsd -i and see if they are the same.

Well that works for files in the same directory:

$ lsd -li s*
1803502 .rwxr-xr-x user_b user_b 2.7 KB Wed Sep 30 21:22:58 2020 ๏’‰ run.hg38.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏’‰ run.mm10.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏€– run.mm10.sh.link

When files are not in the same directory, it gets complicated :-)

What @M4tT3d is referring to is to get column number two of ls -l:

-rwxr-xr-x 1 user_b user_b 2804 30. Sep 21:22 run.hg38.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh.link

Well that works for files in the same directory:

$ lsd -li s*
1803502 .rwxr-xr-x user_b user_b 2.7 KB Wed Sep 30 21:22:58 2020 ๏’‰ run.hg38.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏’‰ run.mm10.sh
1787951 .rwxr-xr-x user_b user_b 1.5 KB Wed Sep 30 21:25:42 2020 ๏€– run.mm10.sh.link

When files are not in the same directory, it gets complicated :-)

What @M4tT3d is referring to is to get column number two of ls -l:

-rwxr-xr-x 1 user_b user_b 2804 30. Sep 21:22 run.hg38.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh
-rwxr-xr-x 2 user_b user_b 1514 30. Sep 21:25 run.mm10.sh.link

Yes. It is exactly what I mean

I, too, would love to see this feature added. It's the only thing that is preventing me from using lsd full-time instead of colorls.

Hey, I want to contribute to this issue. Is there a recommended way to go about implementing this or should I peruse the ls code base ?
P.S. I am new to Rust and I want to get started with contributing to Rust projects.

hi @TheAlakazam , Thanks for trying to implement this!

previously, I have done an inode options for lsd, it may not be the recommended way, but I could be a reference if needed.

https://github.com/Peltoche/lsd/pull/296

feel free to ask any questions

I couldn't get the inode numbers to show with any combination of ls or lsd -i. My current workaround is an alias that uses command to ignore lsd for inode lists.
alias li=command ls -li

@tomWhilbert You might be using an older version of lsd. Version 0.18.0 has support for -i and --inode.

I have version 0.16.0 Its installed via Arch Community repo. Guess I'll wait for the update.

0.18.0 is available in AUR as of now.

I uninstalled with pacman and installed using cargo. All is good now, thanks.

Hi, I wanted to ask if this should be implemented inside the INode struct, because hard link numbers is a part of the inode metadata ? The MetaDataExt crate has a method for getting the number of hardlinks to an inode.

maybe a standalone mod would be a better choice? The hard links number feels more like a standalone concept, although hard-linked files used the same inode number.

As @zwpaper suggested think we could keep it as a separate file as that way it would align with the idea of having one file per block (parsing, rendering etc). Also, we could add something like inode-count (better names welcome) for block name and an INodeCount enum in display.

Ok, I will create a new mod. Names for the mod are welcome, even I am stumped as to what to name it. I will be going with INodeCount for now as per @meain's suggestion.

You can now do lsd --blocks permission,links,user,group,size,date,name or better, have this as the blocks in the config file to get the result you are looking for. This change is available currently in master and should be out in next release.
Decided to not add it to default long listing behavior for now. There is some color change planned and I thought it would be better if this lands fully after that.

Looks like the change has made it into v0.20.1, @meain. From what I can see so far, the hardlink count is, indeed, working now. Thank you so much! ๐Ÿ˜ƒ

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Koovu picture Koovu  ยท  7Comments

jcassee picture jcassee  ยท  5Comments

ngirard picture ngirard  ยท  6Comments

Gerrit-K picture Gerrit-K  ยท  8Comments

spencerwooo picture spencerwooo  ยท  3Comments