Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Color certain directories a different color #206

Closed
securisec opened this issue Aug 13, 2018 · 7 comments
Closed

Feature request: Color certain directories a different color #206

securisec opened this issue Aug 13, 2018 · 7 comments

Comments

@securisec
Copy link

I am not sure if this feature already exists, but if not, I would like to make a feature request.

Feature: Color certain directory patterns a different color. Example: *_vnev would be colored cyan.

Use case: I often use a lot of virtualenvs for python, and my directories always end with the prefix _venv. It would be great to visually differentiate those directories with a color and icon.

@JustinHallquist
Copy link

Hey I have no problem tackling this.

Are we looking for this feature to be as specific as adding just the color to folders prefixed with *_vnev or something more general?

Assuming general, for requirements, are we looking for an additional flag to pass that adds colors based on grouped folder suffixes that occur say more than twice?

folder_1_a - new color
folder_2_a - new color
folder_1_b - default

Or would it be a default feature?

Additionally, since the color map is hardcoded, we could do something like add 5 new colors for these grouped folders and just mod repeat over them if someone had a folder structure loaded with this scenario.

thoughts?

@securisec
Copy link
Author

securisec commented Oct 7, 2018

@JustinHallquist i do like your proposal. the more general approach seems to be ideal, although if user can override general using the config file to specify a suffix, then that would be good also. either way works. but, the issue with the count based suffix coloring is that what if in my scenario, i have one one something_venv folder? then it wouldnt color it. this is where having control the suffix might be beneficial.

i dont know ruby, but from a pseudo code level, here is my idea.

- read conf file, lets say dirs.yaml
- suffix could be key, while value is color, Ex:
    _venv: lavenderblush
    _test: linen
    _output: slateblue
    ...
- color the dirs with those suffix as the key with the color in the value. 

This proposal gets rid of the need for an additional flag being passed. and is also nicely scaleable. also, in the future, other directory specific features could be added, like adding specific icons to directories with suffixs etc

@JustinHallquist
Copy link

I see, thanks for the clarification. I was under the impression we want to color directories with duplicate suffixes in general, not based on existence of suffixes themselves, so that was a misunderstanding on my part.

I think, with the clarification, we would want to avoid a default and leave it up to the user to configure. Feel free to elaborate on use cases for a default though.

The approach you outlined above makes sense -- so the idea would, then, be to have an extension in the yaml for additional suffixes?

    0 # Main Colors
    1 unrecognized_file: gold
    2 recognized_file:   lime
    3 dir:               dodgerblue
    4 suffixes:
    5   _venv:           lavenderblush
    6   _test:           linen

It would be pretty simple to extend that paradigm to prefixes and possibly a regex/wildcard matcher later on if requested, but I think this would be a good start.

thoughts?

@securisec
Copy link
Author

Yes, I agree with leaving the configuration upto the user. I agree with your idea completely.

@JustinHallquist
Copy link

sorry for the delay, PR is up.

@securisec
Copy link
Author

Hey @JustinHallquist , what was your final design? have a dirs.yaml file, or put the postfixes in another config section?

@JustinHallquist
Copy link

My understanding is that as long as you have:
dir_suffixes in a yaml in either of these dirs, it'll work as intended

      @filepath = File.join(File.dirname(__FILE__),"../yaml/#{filename}")
      @user_config_filepath = File.join(Dir.home, ".config/colorls/#{filename}")

so a user can add it to their config or directly on the colors yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants