Lsd: Use terminal color scheme

Created on 27 Dec 2018  路  16Comments  路  Source: Peltoche/lsd

Expected behavior

lsd uses colors from my terminal color scheme, being consistent with all the other command line tools.

Actual behavior

It appears lsd uses hard-coded colors, instead of the terminal color scheme. The hard coded colors don't look as nice. See screenshot below.

image

My terminal colors:
image

kinbug

Most helpful comment

Would you be open to using terminal color scheme behind a flag?

It really does seem like expected behavior; CLI tools usually respect terminal colors.

All 16 comments

Hello @chmln,

As everyone has its own color theme it will be very difficult to make everyone happy. There is a currently a PR (#84) which aim to integrate the LS_COLOR variable to lsd. I think it could solve you issue as you will be able to customize your colors as much as you want. I hope we will be able to merge it soon.

This is sound as a solution to your problem?

Hey, thanks for responding so fast!

While LS_COLORS is one solution, the easiest way to keep everyone happy is to use built-in terminal ANSI colors. This would remove the need for every user to customize via LS_COLORS to get readable colors.

Fixed colors make more sense for webpages, but not so much for terminals where the background colors can vary a lot. Powershell, for instance, has a dark blue background by default. I use dark gray. In both cases, contrast suffers. Support for built-in colors would be a huge usability win.

Its rather easy to implement proper ANSI color support. It would entail just using e.g. ansi_term::Colour::Blue instead of Color::Fixed(33) // DodgerBlue1. If you're open to the idea, I can submit a PR :)

I fear the will be not enough colors with the basic ANSI colors. Most of the peoples expects to find the same result than the README but there color theme would change it and it could be deceptive.

There is another possible solution: as proposed into #92, it could be a good idea to propose a configuration file with a custom theme.

As we will not directly implement the proposed solution I set this issue as close

Would you be open to using terminal color scheme behind a flag?

It really does seem like expected behavior; CLI tools usually respect terminal colors.

It seems that a lot of people want this feature so I reopen this issue in order to find a solution.

I see three solutions:

  • Move every existing colors to ANSI colors. This will break the output for many peoples.
  • Add a flag to choose between hardcoded colors vs AINSI colors.

The first solution seems to be the most standard one, that why I would tend to choose this one but it include a big fat change for current users and that's not good...

Any suggestions?

I don't think that it'll be so destructive to the existing users. See how exa handles it at https://github.com/ogham/exa/blob/master/src/style/colours.rs

It seems that a lot of people want this feature so I reopen this issue in order to find a solution.

I see three solutions:

  • Move every existing colors to ANSI colors. This will break the output for many peoples.
  • Add a flag to choose between hardcoded colors vs AINSI colors.

The first solution seems to be the most standard one, that why I would tend to choose this one but it include a big fat change for current users and that's not good...

Any suggestions?

I like the first option too. We could also add custom colors behind a flag in the future. You are correct that it would change existing colors for users so perhaps we could bump the semver version to indicate that.

That being said, maybe color changes are not breaking functional changes.

What do you think?

My vote would be to default to ansi similar to exa then introduce theme support (#92) for people that want to fully customize colors.

Just agreeing here that exa does a very nice job of using a user's already-chosen colors:

image

I'm sorry I don't have much time in the next few days so I hope that someone would like to make a PR. I should be a easy one because there is not logic changes.

I can take a look.

@thekashifmalik That would be awesome, I can help you if you need any help with navigating the codebase.

It seems to use the terminal colors for me if I just call ls first in fish.
screenshot-2019-08-06_23:52:01
Not sure why this works for me, but I am using version 0.15.1 and have tested this in urxvt and st. :thinking: So to make this automatically happen for all my terminals, I added ls > /dev/null to my config.fish file, and now it just uses the terminal colors even for my first call to lsd in a terminal.

@Kevin-Mok From what I can understand from here, this happens because fish sets the LS_COLORS variable when you call ls. lsd does use LS_COLORS to figure out the user colors.

@Peltoche A simple fix would be completely let lscolors take care of colors.

@Peltoche A simple fix would be completely let lscolors take care of colors.

This would be the best solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

meain picture meain  路  8Comments

saumyajyoti picture saumyajyoti  路  7Comments

augustobmoura picture augustobmoura  路  5Comments

Gerrit-K picture Gerrit-K  路  8Comments

alichtman picture alichtman  路  3Comments