lsd
lsd copied to clipboard
Create a git integration
Can you explain what kind of git integration you're looking to add?
Hello @alichtman,
There is no defined specs yet. This feature is already implemented by the colorls and the exa projects, I think it can be a good start to check how they do it.
There is an example on the exa website: https://the.exa.website/features/git
Basically there is a new column that displays the git status for the files in the listed directory. (new, modified etc..)
Seems cool. I think that we can do something even better with the icons support. I don't know if we should add a new icons for the git status or just override the existing one. We can also add a new column of course.
Another tool to check out that displays the git status of files is ranger. I like their use of icons, and I also like that they display the git status of entire repos too, so you could ls -l the current directory and see which repos are dirty. Screenshot.
Maybe add a option or a flag to hide files based on the .gitignore file
I definitely support this. Would be useful to be able to see the current git status of files and also being able to hide files based on the .gitignore file.
+1 from me! I'd really love to have this as well, it's the only thing I still miss from exa/colorls!
+1!!!!
I like this idea; maybe I can do it. Is there already someone on this issue ?
About the icons, if we want funny glyphs, my suggestions are (from https://www.nerdfonts.com/cheat-sheet)
* check (-): nf-fa-check f00c
* modified (M): nf-fa-gear f013
* uknown (?): nf-fa-user_secret f21b
* ignored (!) : nf-mdi-ghost f79f (or nf-fa-exclamation f12a)
* new (+) : nf-mdi-login_variant fafb

The display should be with two columns (staged, not staged)
To get git info, I can use libgit2 (https://github.com/rust-lang/git2-rs)
Is there any other constraint ?
Hi @hpwxf , There is noone working on this right now, please feel free to take this up and thanks for contributing to LSD!
as the icons part, maybe we should have @meain 's attention, for my personal opinion, it is cute! XD
PS: I was thinking to work on a configuration file for the icons after the theme one, so do not let the glyphs stop your progress
Hey @hpwxf, thanks a lot for taking looking into this. I have not been able to fully think through it but here are few things that I wanted to mention.
I don't think separating the output of ls to two columns would be a good idea, this should be just a "block" similar to size or date. As for the representation, we could use how git-status represents it with two items (working tree and index). This would make the data familiar to read. We kinda loose the details on partially staged files for example if we stick to just one char/icon.
About the icons, I think icons should be optional as this feature should also be usable by people who do not have the proper fonts setup. We could have this configurable and make it use icons, but I am not also worried if having two icons close together would look good.
Related to the implementation, when listing a top level folder lsd should be able to notify even if there is some change in some file that is under a specific folder.
To define a status for a directory, I suggest to use a kind of max on the status of the files inside. I use this order:
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum GitStatus {
/// No changes
Unmodified,
/// Entry is ignored item in workdir
Ignored,
/// Entry does not exist in old version
New,
/// Type of entry changed between old and new
Typechange,
/// Entry does not exist in new version
Deleted,
/// Entry was renamed between old and new
Renamed,
/// Entry content changed between old and new
Modified,
/// Entry in the index is conflicted
Conflicted,
}
it means that a conflict will always be shown whatever the other modifications; if no conflict, the second most important status is Modified...
Below, a output example (fancy icons will come later). For this example, in the previous commit, each sub/directory contained two files file1 and file2.

Is it what you expect ?
@hpwxf That sounds good.
Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.
Completely unsolicited, but Git Integration in a manner similar to colorls in the grid view would be really nice for at a glance information.
After this PR is merged, this seems to be a doable improvement.
I love lsd, I prefer it over exa but I miss the Git Integration, why has this feature not been considered yet?
For sure, PR #495 should be updated.
Is there only this remark https://github.com/Peltoche/lsd/pull/495#issuecomment-965972260 to solve?
Any news on this?
Thank you to ask. It seems useful to update my PR. I will try to do on next Wednesday (Feb 15th). I hope the code hasn't changed too much since my first version.
@hpwxf Thanks for the interest. I unfortunately don't have much time these days to look into major features in lsd. I'm fine if @zwpaper can take up review of this one. Just wanted to give you a heads up so as to not waste your time.
Hi @meain @hpwxf, I also do not have much time for this significant feature, but luckily we have already done most of the work previously, let's keep going and I will try my best to make it happen.
I'm rebasing my previous work on master branch. --git option seems to work again.
I have many #[cfg(feature = "git")] to support git as an optional feature.
What do you prefer? default feature or optional feature ?
I'm thinking it could be enabled on systems that support it. Don't think there is any point in keeping it optional.
Ok; the only unsupported arches are:
- ~arm-unknown-linux-gnueabihf~ (now supported by removing non necessary features from git2-rs)
- i686-pc-windows-gnu
Before the PR, I've just something to check about
- [x] display of git symbols even if
--icons=never - [x] Simplify the deactivation of the
gitfeature (when not supported; cf list above) - [x] proper icons for fancy theme; any suggestion is welcome (cf https://github.com/Peltoche/lsd/issues/7#issuecomment-787442823)
- [ ] issues related in https://github.com/Peltoche/lsd/pull/495#issuecomment-965972260
and it should be done (hopefully in a few days).
It's almost done. To fix issues shown in my previous PR, I need to know how to manage the case where we have:
- a sub-directory 'subdir' that uses git (but not the current one): show or not a git status for
subdir? - a sub-directory that uses git and the current one also uses git + option
--tree: show git status related to current dir or a status as if we usegit statusinside each subdirectory?
In other words, do you consider that the output of exa -l --git [--tree] is what we want?
Here my demo to plau this demo.zip
And some comparisons on it between exa and my proposal.
Case 1.:

Case 2.:

hi @hpwxf, in my opinion, I would vote +1 for the exa output, as git status also output like this.
I'm waiting two days for any other suggestions, and then I push my PR.
/close
/close