Lsd: Create a git integration

Created on 4 Dec 2018  路  14Comments  路  Source: Peltoche/lsd

kinenhancement

Most helpful comment

Maybe add a option or a flag to hide files based on the .gitignore file

All 14 comments

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
Capture d鈥櫭ヽran 2021-02-28 脿 13 11 49

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.
Snapshot

Is it what you expect ?

@hpwxf That sounds good.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EppO picture EppO  路  3Comments

meain picture meain  路  8Comments

jfernandz picture jfernandz  路  6Comments

dalecurtis picture dalecurtis  路  3Comments

lez picture lez  路  3Comments